From 65c8735974a5adc99bdcfc174ef5d730b58a2668 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:19:47 +0000 Subject: [PATCH 01/84] Transform error messages --- lib/field_names.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index f2dd8da..5187fdd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -114,7 +114,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -189,7 +189,7 @@ function factory( fields ) { view = new DataView( arg ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset ); @@ -207,7 +207,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index c0e0800..e878339 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 4a43231..e5fd433 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 2309f4b..3f0fa26 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 28082e8..5d0fbe2 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 6f1f0c6..278a3ad 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index b476cfa..f03a711 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -200,7 +200,7 @@ function linearFormat( struct, fields ) { function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -208,7 +208,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 2d237ec..9b8378f 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@stdlib/number-ctor": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From d6d67fec872a5d7a57e2f7ed9b085932faae3de4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:20:34 +0000 Subject: [PATCH 02/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 49 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 135 - examples/union.js | 80 - examples/union_with_complex.js | 75 - examples/union_with_struct.js | 99 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/get_bigint.js | 56 - lib/get_boolean.js | 57 - lib/get_complex.js | 68 - lib/get_number.js | 56 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 52 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 474 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 98 - lib/set_boolean.js | 91 - lib/set_complex.js | 95 - lib/set_number.js | 101 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 150 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 224 - package.json | 103 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - 90 files changed, 4863 insertions(+), 7669 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -301,7 +292,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fedac65..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(zs,oe){"use strict";var gt="__@@##$$@@__struct_buffer__@@$$##@@__";oe.exports=gt});var W=u(function(Gs,fe){"use strict";var pt="Struct";fe.exports=pt});var H=u(function(Ws,ve){"use strict";var mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ve.exports=mt});var ce=u(function(Hs,le){"use strict";var yt=require("@stdlib/assert-is-little-endian"),qt=y();function ht(e,i){return r;function r(){return this[qt][i](e.byteOffset,yt)}}le.exports=ht});var pe=u(function(Ys,ge){"use strict";var dt=require("@stdlib/assert-is-little-endian"),Et=require("@stdlib/boolean-ctor"),wt=y();function Tt(e,i){return r;function r(){return Et(this[wt][i](e.byteOffset,dt))}}ge.exports=Tt});var he=u(function($s,qe){"use strict";var me=require("@stdlib/assert-is-little-endian"),xt=require("@stdlib/complex-cmplx"),ye=y(),Ot={complex128:"float64",complex64:"float32",complex32:"float16"};function bt(e,i){return r;function r(){var t=this[ye][i](e.byteOffset,me),n=this[ye][i](e.byteOffset+e.byteLength/2,me);return xt(t,n,Ot[e.type])}}qe.exports=bt});var Ee=u(function(Xs,de){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=y();function At(e,i){return r;function r(){return this[St][i](e.byteOffset,It)}}de.exports=At});var Te=u(function(Ks,we){"use strict";var Ft=y();function Vt(e){return i;function i(){var r=this[Ft];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}we.exports=Vt});var Oe=u(function(Qs,xe){"use strict";var Nt=require("@stdlib/array-typed"),Pt=y();function Rt(e){return i;function i(){var r=this[Pt];return Nt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}xe.exports=Rt});var Ie=u(function(Zs,be){"use strict";var _t=y();function Lt(e){return i;function i(){var r,t,n,a;for(t=this[_t],r=t.byteOffset+e.byteOffset,n=[],a=0;a0?null:new TypeError(ea("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=ra});var hr=u(function(Tu,qr){"use strict";var ta=require("@stdlib/assert-is-string").isPrimitive,ia=require("@stdlib/string-format");function na(e,i){return ta(e)?null:new TypeError(ia("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=na});var Er=u(function(xu,dr){"use strict";var aa=require("@stdlib/assert-is-positive-integer").isPrimitive,sa=require("@stdlib/string-format");function ua(e,i){return aa(e)?null:new TypeError(sa("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=ua});var Tr=u(function(Ou,wr){"use strict";var oa=require("@stdlib/assert-is-boolean").isPrimitive,fa=require("@stdlib/string-format");function va(e,i){return oa(e)?null:new TypeError(fa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}wr.exports=va});var Or=u(function(bu,xr){"use strict";var la=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=la});var Sr=u(function(Iu,Ir){"use strict";var ca=require("@stdlib/array-base-assert-contains"),ga=require("@stdlib/array-base-join"),pa=require("@stdlib/string-format"),ma=V(),br=Or();function ya(e){return ca(br,e)||ma(e)?null:new TypeError(pa('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",ga(br,", "),e))}Ir.exports=ya});var Fr=u(function(Su,Ar){"use strict";var qa=require("@stdlib/array-base-assert-contains"),ha=require("@stdlib/array-base-join"),da=require("@stdlib/string-format");function Ea(e){return i;function i(r,t){return qa(e,r)?null:new TypeError(da('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ha(e,", "),r))}}Ar.exports=Ea});var Nr=u(function(Au,Vr){"use strict";function wa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=wa});var Rr=u(function(Fu,Pr){"use strict";var Ta=require("@stdlib/ndarray-base-bytes-per-element");function xa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Ta(e.type),e.length&&(i*=e.length),i}Pr.exports=xa});var Lr=u(function(Vu,_r){"use strict";var Oa=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Oa});var Dr=u(function(Nu,Br){"use strict";var ba={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=ba});var re=u(function(Pu,Mr){"use strict";var Ia=require("@stdlib/assert-has-property"),Sa=require("@stdlib/array-base-join"),Aa=require("@stdlib/utils-constant-function"),Fa=require("@stdlib/string-format"),Va=pr(),Na=V(),Pa=yr(),Ra=hr(),_a=Er(),Ur=Tr(),La=Sr(),Ba=Fr(),Da=Nr(),Ua=Rr(),Ca=Lr(),Ma=Dr(),Cr=["name","type"],ka={name:Pa,type:La,description:Ra,length:_a,enumerable:Ur,writable:Ur,default:Aa(null),castingMode:Ba(Ca)};function Ja(e,i){var r,t,n,a,s;for(r=Da(),s=0;si&&(i=r);return i}kr.exports=za});var Gr=u(function(_u,zr){"use strict";var Ga=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),ie=require("@stdlib/string-format"),Wa=P(),Ha=ee(),Ya=re(),$a=te();function Xa(e){var i,r,t,n,a,s,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(a=e[o-1],a.padding=t,ne(s)&&Qr(a.fields,t)),s.byteOffset=n,ne(s))for(p=0;pI&&(I=F);for(n="%"+I+"s",a="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&v.byteOffset===i[m-1].byteOffset)){for(m1?s=" (byte %u)":s="",c){for(o=" => union: %s",l=[],R=m+1;R[%u]",w.name,w.type,T%w.alignment)),R+=1;o=q(o,l.join(", "))}else o="";l=q(s+o,T%v.alignment),v.length?E=q(a,q("%s[%u]%s",v.type,gs(T/v.alignment),l)):E=q(a,q("%s%s",v.type,l)),f.push(q(p,O,h,E)),g+=1}for(T=0;T"}at.exports=ys});var ot=u(function(ku,ut){"use strict";var qs=require("@stdlib/assert-is-collection"),hs=require("@stdlib/assert-is-complex-like"),ds=require("@stdlib/assert-is-function"),Es=require("@stdlib/array-to-json"),ws=V();function Ts(e,i){var r,t,n,a;for(r={},a=0;a0){if(!Is(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,ue,b),I!==void 0){for(O=As(void 0,s.length),E={},v=0;v0?c=arguments[0]:c={},Us(this,s,c)}),d(l.prototype,"toJSON",function(){if(!(this instanceof l))throw new Error("invalid invocation. `this` is not a struct instance.");return Cs(this,s)}),l}lt.exports=Ms});var ks=ct();module.exports=ks; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8828372..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAwBA,IAAIC,GAAmB,QAAS,iCAAkC,EAC9DC,GAAiB,IAarB,SAASC,GAAWC,EAAKC,EAAS,CACjC,OAAOC,EAQP,SAASA,GAAS,CACjB,OAAO,KAAMJ,EAAe,EAAGG,CAAO,EAAGD,EAAI,WAAYH,EAAiB,CAC3E,CACD,CAKAD,GAAO,QAAUG,KCvDjB,IAA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GAAe,KAAMS,EAAQmB,CAAK,CAC1C,CAAC,EAaDnD,EAAamC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOX,GAAa,KAAMQ,CAAO,CAClC,CAAC,EAEMG,CACR,CAKApC,GAAO,QAAU0B,KCpZjB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isPositiveInteger", "isDataView", "isObject", "CTOR_NAME", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "floor", "format", "FORMATS", "isFormat", "linearFormat", "struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "toString", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 98e208e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 982ac40..0000000 --- a/examples/union.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index 13eefe5..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 85d5c64..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bea1144 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.0-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.2-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import{isPrimitive as A}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import{isPrimitive as R}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import{isPrimitive as G}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as rt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import it,{factory as ot}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var pt="__@@##$$@@__struct_buffer__@@$$##@@__",ct="Struct",gt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ht={complex128:"float64",complex64:"float32",complex32:"float16"};function yt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[pt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return it(It,t)||Tt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",a(It,", "),t))},description:function(t,e){return rt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return G(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ut,writable:Ut,default:st(null),castingMode:(Jt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return it(Jt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,a(Jt,", "),t))})};function _t(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function At(t){var e,n,s,r,a,l,d;if(0===(e=t.fields).length)return null;for(s=[],d=0;dh&&(h=y);for(s="%"+h+"s",r="// %s",a="%s: %s %s",m=0,d=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(f=w1?" (byte %u)":"",f){for(o=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;o=u(o,l.join(", "))}else o="";l=u(i+o,x%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,z(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),d.push(u(a,p,c,g)),m+=1}for(x=0;x"}function zt(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,pt,g),void 0!==h){for(d=l(void 0,x.length),c={},E=0;E0&&((i=t[a-1]).padding=s,Ft(o)&&Bt(i.fields,s)),o.byteOffset=r,Ft(o))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,o;for(n={},o=0;o} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport CTOR_NAME from './ctor_name.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","CTOR_NAME","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isPositiveInteger","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;y0MAuBA,IAAIA,GAAiB,wCCDjBC,GAAY,SCAZC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,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EAAG3D,EAAE3E,KAAMpE,GAEtB+I,EAAEnB,SACbiF,EAAmCH,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEnDqM,EAAkCI,EAAG3D,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CL+VauL,CAA0BxB,EAAOyB,UAAW7B,GAiBxDa,EAAaT,EAAOyB,UAAW,YAAY,WAE1C,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAOlB,OAAOmK,GAAevL,KAAMyJ,EALvBQ,UAAUvK,OAAS,EAChBuK,UAAW,GAEX,CAAA,EAGV,IAaCK,EAAaT,EAAOyB,UAAW,UAAU,WACxC,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OMzaF,SAAiByG,EAAQrC,GACxB,IAAI1F,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI9B,EAAQzF,IACE4C,MACTmB,EAAchC,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CNqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 29e0475..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 2f6b307..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - return Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index 34d39f9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 131d179..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index 58b3ad7..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var CTOR_NAME = require( './ctor_name.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - value.constructor.name === CTOR_NAME && - isPositiveInteger( value.constructor.byteLength ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5187fdd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,474 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, byteLength ); - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index e878339..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index e5fd433..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 3f0fa26..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var re; - var im; - - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index 5d0fbe2..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 278a3ad..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,150 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index f03a711..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear' -]; -var isFormat = contains( FORMATS ); - - -// FUNCTIONS // - -/** -* Serializes a `struct` instance to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = struct.constructor.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct, fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 9b8378f..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,28 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "examples": "make examples" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -33,84 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -123,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..005c56a --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); From f3a22b48824f085ea084f1350cb50c7be8f39fd2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:25:41 +0000 Subject: [PATCH 03/84] Transform error messages --- lib/field_names.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index f2dd8da..5187fdd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -114,7 +114,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -189,7 +189,7 @@ function factory( fields ) { view = new DataView( arg ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset ); @@ -207,7 +207,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index c0e0800..e878339 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 4a43231..e5fd433 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 2309f4b..3f0fa26 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 28082e8..5d0fbe2 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 6f1f0c6..278a3ad 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index b476cfa..f03a711 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -200,7 +200,7 @@ function linearFormat( struct, fields ) { function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -208,7 +208,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 2d237ec..9b8378f 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@stdlib/number-ctor": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From dcddbb0a007b6ba83a6b2d16f5a790fe4eb715fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:25:59 +0000 Subject: [PATCH 04/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bea1144..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.0-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.2-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import{isPrimitive as A}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import{isPrimitive as R}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import{isPrimitive as G}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as rt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import it,{factory as ot}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var pt="__@@##$$@@__struct_buffer__@@$$##@@__",ct="Struct",gt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ht={complex128:"float64",complex64:"float32",complex32:"float16"};function yt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[pt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return it(It,t)||Tt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",a(It,", "),t))},description:function(t,e){return rt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return G(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ut,writable:Ut,default:st(null),castingMode:(Jt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return it(Jt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,a(Jt,", "),t))})};function _t(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function At(t){var e,n,s,r,a,l,d;if(0===(e=t.fields).length)return null;for(s=[],d=0;dh&&(h=y);for(s="%"+h+"s",r="// %s",a="%s: %s %s",m=0,d=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(f=w1?" (byte %u)":"",f){for(o=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;o=u(o,l.join(", "))}else o="";l=u(i+o,x%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,z(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),d.push(u(a,p,c,g)),m+=1}for(x=0;x"}function zt(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,pt,g),void 0!==h){for(d=l(void 0,x.length),c={},E=0;E0&&((i=t[a-1]).padding=s,Ft(o)&&Bt(i.fields,s)),o.byteOffset=r,Ft(o))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,o;for(n={},o=0;o} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport CTOR_NAME from './ctor_name.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","CTOR_NAME","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isPositiveInteger","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;y0MAuBA,IAAIA,GAAiB,wCCDjBC,GAAY,SCAZC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC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wH,EACAvH,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/BxB,EAAMiB,GADN8H,EAAI9B,EAAQzF,IAEZvB,EAAM+E,GAAQ+D,GACTA,EAAEpB,WACDoB,EAAEnB,SACN+E,EAAsBD,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEtC2M,EAAqBF,EAAG3D,EAAE3E,KAAMpE,GAEtB+I,EAAEnB,SACbiF,EAAmCH,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEnDqM,EAAkCI,EAAG3D,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CL+VauL,CAA0BxB,EAAOyB,UAAW7B,GAiBxDa,EAAaT,EAAOyB,UAAW,YAAY,WAE1C,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAOlB,OAAOmK,GAAevL,KAAMyJ,EALvBQ,UAAUvK,OAAS,EAChBuK,UAAW,GAEX,CAAA,EAGV,IAaCK,EAAaT,EAAOyB,UAAW,UAAU,WACxC,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OMzaF,SAAiByG,EAAQrC,GACxB,IAAI1F,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI9B,EAAQzF,IACE4C,MACTmB,EAAchC,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CNqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 005c56a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 494263a71551ba00a468e59ed077f257fc85db6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:26:47 +0000 Subject: [PATCH 05/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 135 - examples/union.js | 80 - examples/union_with_complex.js | 75 - examples/union_with_struct.js | 99 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/get_bigint.js | 56 - lib/get_boolean.js | 57 - lib/get_complex.js | 68 - lib/get_number.js | 56 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 52 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 474 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 98 - lib/set_boolean.js | 91 - lib/set_complex.js | 95 - lib/set_number.js | 101 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 150 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 224 - package.json | 103 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - 90 files changed, 4863 insertions(+), 7670 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +293,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fedac65..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(zs,oe){"use strict";var gt="__@@##$$@@__struct_buffer__@@$$##@@__";oe.exports=gt});var W=u(function(Gs,fe){"use strict";var pt="Struct";fe.exports=pt});var H=u(function(Ws,ve){"use strict";var mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ve.exports=mt});var ce=u(function(Hs,le){"use strict";var yt=require("@stdlib/assert-is-little-endian"),qt=y();function ht(e,i){return r;function r(){return this[qt][i](e.byteOffset,yt)}}le.exports=ht});var pe=u(function(Ys,ge){"use strict";var dt=require("@stdlib/assert-is-little-endian"),Et=require("@stdlib/boolean-ctor"),wt=y();function Tt(e,i){return r;function r(){return Et(this[wt][i](e.byteOffset,dt))}}ge.exports=Tt});var he=u(function($s,qe){"use strict";var me=require("@stdlib/assert-is-little-endian"),xt=require("@stdlib/complex-cmplx"),ye=y(),Ot={complex128:"float64",complex64:"float32",complex32:"float16"};function bt(e,i){return r;function r(){var t=this[ye][i](e.byteOffset,me),n=this[ye][i](e.byteOffset+e.byteLength/2,me);return xt(t,n,Ot[e.type])}}qe.exports=bt});var Ee=u(function(Xs,de){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=y();function At(e,i){return r;function r(){return this[St][i](e.byteOffset,It)}}de.exports=At});var Te=u(function(Ks,we){"use strict";var Ft=y();function Vt(e){return i;function i(){var r=this[Ft];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}we.exports=Vt});var Oe=u(function(Qs,xe){"use strict";var Nt=require("@stdlib/array-typed"),Pt=y();function Rt(e){return i;function i(){var r=this[Pt];return Nt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}xe.exports=Rt});var Ie=u(function(Zs,be){"use strict";var _t=y();function Lt(e){return i;function i(){var r,t,n,a;for(t=this[_t],r=t.byteOffset+e.byteOffset,n=[],a=0;a0?null:new TypeError(ea("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=ra});var hr=u(function(Tu,qr){"use strict";var ta=require("@stdlib/assert-is-string").isPrimitive,ia=require("@stdlib/string-format");function na(e,i){return ta(e)?null:new TypeError(ia("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=na});var Er=u(function(xu,dr){"use strict";var aa=require("@stdlib/assert-is-positive-integer").isPrimitive,sa=require("@stdlib/string-format");function ua(e,i){return aa(e)?null:new TypeError(sa("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=ua});var Tr=u(function(Ou,wr){"use strict";var oa=require("@stdlib/assert-is-boolean").isPrimitive,fa=require("@stdlib/string-format");function va(e,i){return oa(e)?null:new TypeError(fa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}wr.exports=va});var Or=u(function(bu,xr){"use strict";var la=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=la});var Sr=u(function(Iu,Ir){"use strict";var ca=require("@stdlib/array-base-assert-contains"),ga=require("@stdlib/array-base-join"),pa=require("@stdlib/string-format"),ma=V(),br=Or();function ya(e){return ca(br,e)||ma(e)?null:new TypeError(pa('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",ga(br,", "),e))}Ir.exports=ya});var Fr=u(function(Su,Ar){"use strict";var qa=require("@stdlib/array-base-assert-contains"),ha=require("@stdlib/array-base-join"),da=require("@stdlib/string-format");function Ea(e){return i;function i(r,t){return qa(e,r)?null:new TypeError(da('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ha(e,", "),r))}}Ar.exports=Ea});var Nr=u(function(Au,Vr){"use strict";function wa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=wa});var Rr=u(function(Fu,Pr){"use strict";var Ta=require("@stdlib/ndarray-base-bytes-per-element");function xa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Ta(e.type),e.length&&(i*=e.length),i}Pr.exports=xa});var Lr=u(function(Vu,_r){"use strict";var Oa=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Oa});var Dr=u(function(Nu,Br){"use strict";var ba={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=ba});var re=u(function(Pu,Mr){"use strict";var Ia=require("@stdlib/assert-has-property"),Sa=require("@stdlib/array-base-join"),Aa=require("@stdlib/utils-constant-function"),Fa=require("@stdlib/string-format"),Va=pr(),Na=V(),Pa=yr(),Ra=hr(),_a=Er(),Ur=Tr(),La=Sr(),Ba=Fr(),Da=Nr(),Ua=Rr(),Ca=Lr(),Ma=Dr(),Cr=["name","type"],ka={name:Pa,type:La,description:Ra,length:_a,enumerable:Ur,writable:Ur,default:Aa(null),castingMode:Ba(Ca)};function Ja(e,i){var r,t,n,a,s;for(r=Da(),s=0;si&&(i=r);return i}kr.exports=za});var Gr=u(function(_u,zr){"use strict";var Ga=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),ie=require("@stdlib/string-format"),Wa=P(),Ha=ee(),Ya=re(),$a=te();function Xa(e){var i,r,t,n,a,s,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(a=e[o-1],a.padding=t,ne(s)&&Qr(a.fields,t)),s.byteOffset=n,ne(s))for(p=0;pI&&(I=F);for(n="%"+I+"s",a="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&v.byteOffset===i[m-1].byteOffset)){for(m1?s=" (byte %u)":s="",c){for(o=" => union: %s",l=[],R=m+1;R[%u]",w.name,w.type,T%w.alignment)),R+=1;o=q(o,l.join(", "))}else o="";l=q(s+o,T%v.alignment),v.length?E=q(a,q("%s[%u]%s",v.type,gs(T/v.alignment),l)):E=q(a,q("%s%s",v.type,l)),f.push(q(p,O,h,E)),g+=1}for(T=0;T"}at.exports=ys});var ot=u(function(ku,ut){"use strict";var qs=require("@stdlib/assert-is-collection"),hs=require("@stdlib/assert-is-complex-like"),ds=require("@stdlib/assert-is-function"),Es=require("@stdlib/array-to-json"),ws=V();function Ts(e,i){var r,t,n,a;for(r={},a=0;a0){if(!Is(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,ue,b),I!==void 0){for(O=As(void 0,s.length),E={},v=0;v0?c=arguments[0]:c={},Us(this,s,c)}),d(l.prototype,"toJSON",function(){if(!(this instanceof l))throw new Error("invalid invocation. `this` is not a struct instance.");return Cs(this,s)}),l}lt.exports=Ms});var ks=ct();module.exports=ks; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8828372..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,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9B,EAAe,EAAE,MAC9B,CAAC,EAcDb,EAAamC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIO,EACJ,GAAK,CAAClC,GAAU2B,CAAI,EACnB,MAAM,IAAI,UAAW/B,EAAQ,6EAA8E+B,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAK9B,EAAe,EACnB,IAAIF,EAAUuC,EAAKA,EAAI,WAAYA,EAAI,UAAW,CAC1D,CAAC,EAGDnB,EAAYhB,GAA0BoB,EAAO,UAAWH,CAAO,EAiB/DhC,EAAamC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF5B,GAAe,KAAMS,EAAQmB,CAAK,CAC1C,CAAC,EAaDnD,EAAamC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOX,GAAa,KAAMQ,CAAO,CAClC,CAAC,EAEMG,CACR,CAKApC,GAAO,QAAU0B,KCpZjB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isPositiveInteger", "isDataView", "isObject", "CTOR_NAME", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "floor", "format", "FORMATS", "isFormat", "linearFormat", "struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "toString", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 98e208e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 982ac40..0000000 --- a/examples/union.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index 13eefe5..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 85d5c64..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..546366d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as J}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as _}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as A}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import{isPrimitive as $}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft="Struct",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Vt,t)||jt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(Vt,", "),t))},description:function(t,e){return Z(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return $(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:Y(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,o(Lt,", "),t))})};function It(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Nt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,B(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function kt(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,lt,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=t[o-1]).padding=s,Et(a)&&Pt(i.fields,s)),a.byteOffset=r,Et(a))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport CTOR_NAME from './ctor_name.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","CTOR_NAME","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isPositiveInteger","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;y5LAuBA,IAAIA,GAAiB,wCCDjBC,GAAY,SCAZC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MA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,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/BxB,EAAMiB,GADN8H,EAAI9B,EAAQzF,IAEZvB,EAAM+E,GAAQ+D,GACTA,EAAEpB,WACDoB,EAAEnB,SACN+E,EAAsBD,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEtC2M,EAAqBF,EAAG3D,EAAE3E,KAAMpE,GAEtB+I,EAAEnB,SACbiF,EAAmCH,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEnDqM,EAAkCI,EAAG3D,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CL+VauL,CAA0BxB,EAAOyB,UAAW7B,GAiBxDa,EAAaT,EAAOyB,UAAW,YAAY,WAE1C,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAOlB,OAAOmK,GAAevL,KAAMyJ,EALvBQ,UAAUvK,OAAS,EAChBuK,UAAW,GAEX,CAAA,EAGV,IAaCK,EAAaT,EAAOyB,UAAW,UAAU,WACxC,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OMzaF,SAAiByG,EAAQrC,GACxB,IAAI1F,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI9B,EAAQzF,IACE4C,MACTmB,EAAchC,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CNqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 29e0475..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 2f6b307..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - return Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index 34d39f9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 131d179..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index 58b3ad7..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var CTOR_NAME = require( './ctor_name.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - value.constructor.name === CTOR_NAME && - isPositiveInteger( value.constructor.byteLength ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5187fdd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,474 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, byteLength ); - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index e878339..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index e5fd433..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 3f0fa26..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var re; - var im; - - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index 5d0fbe2..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 278a3ad..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,150 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index f03a711..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear' -]; -var isFormat = contains( FORMATS ); - - -// FUNCTIONS // - -/** -* Serializes a `struct` instance to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = struct.constructor.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct, fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 9b8378f..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,28 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "examples": "make examples" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -33,84 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -123,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..11314a4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); From e8b464687aa8c48cc8c5f438359c119ed41e0145 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:32:26 +0000 Subject: [PATCH 06/84] Transform error messages --- lib/field_names.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index f2dd8da..5187fdd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -114,7 +114,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -189,7 +189,7 @@ function factory( fields ) { view = new DataView( arg ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset ); @@ -207,7 +207,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index c0e0800..e878339 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 4a43231..e5fd433 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 2309f4b..3f0fa26 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 28082e8..5d0fbe2 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 6f1f0c6..278a3ad 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index b476cfa..f03a711 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -200,7 +200,7 @@ function linearFormat( struct, fields ) { function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -208,7 +208,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 9b11753..74e3965 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@stdlib/number-ctor": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 6b7886a4abf2902f670b7a1dbef6cf5f5ec5df16 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:32:46 +0000 Subject: [PATCH 07/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 546366d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as J}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as _}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as A}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import{isPrimitive as $}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft="Struct",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Vt,t)||jt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(Vt,", "),t))},description:function(t,e){return Z(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return $(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:Y(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,o(Lt,", "),t))})};function It(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Nt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,B(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function kt(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,lt,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=t[o-1]).padding=s,Et(a)&&Pt(i.fields,s)),a.byteOffset=r,Et(a))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport CTOR_NAME from './ctor_name.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","CTOR_NAME","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isPositiveInteger","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;y5LAuBA,IAAIA,GAAiB,wCCDjBC,GAAY,SCAZC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO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AO9F,OAAQK,IAE/BxB,EAAMiB,GADN8H,EAAI9B,EAAQzF,IAEZvB,EAAM+E,GAAQ+D,GACTA,EAAEpB,WACDoB,EAAEnB,SACN+E,EAAsBD,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEtC2M,EAAqBF,EAAG3D,EAAE3E,KAAMpE,GAEtB+I,EAAEnB,SACbiF,EAAmCH,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEnDqM,EAAkCI,EAAG3D,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CL+VauL,CAA0BxB,EAAOyB,UAAW7B,GAiBxDa,EAAaT,EAAOyB,UAAW,YAAY,WAE1C,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAOlB,OAAOmK,GAAevL,KAAMyJ,EALvBQ,UAAUvK,OAAS,EAChBuK,UAAW,GAEX,CAAA,EAGV,IAaCK,EAAaT,EAAOyB,UAAW,UAAU,WACxC,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OMzaF,SAAiByG,EAAQrC,GACxB,IAAI1F,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI9B,EAAQzF,IACE4C,MACTmB,EAAchC,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CNqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 11314a4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf2940b8257ace3af059cec3b5145a7769846ecd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 04:33:09 +0000 Subject: [PATCH 08/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 135 - examples/union.js | 80 - examples/union_with_complex.js | 75 - examples/union_with_struct.js | 99 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/get_bigint.js | 56 - lib/get_boolean.js | 57 - lib/get_complex.js | 68 - lib/get_number.js | 56 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 52 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 474 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 98 - lib/set_boolean.js | 91 - lib/set_complex.js | 95 - lib/set_number.js | 101 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 150 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 224 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 95 files changed, 4863 insertions(+), 8087 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +293,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fedac65..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(zs,oe){"use strict";var gt="__@@##$$@@__struct_buffer__@@$$##@@__";oe.exports=gt});var W=u(function(Gs,fe){"use strict";var pt="Struct";fe.exports=pt});var H=u(function(Ws,ve){"use strict";var mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ve.exports=mt});var ce=u(function(Hs,le){"use strict";var yt=require("@stdlib/assert-is-little-endian"),qt=y();function ht(e,i){return r;function r(){return this[qt][i](e.byteOffset,yt)}}le.exports=ht});var pe=u(function(Ys,ge){"use strict";var dt=require("@stdlib/assert-is-little-endian"),Et=require("@stdlib/boolean-ctor"),wt=y();function Tt(e,i){return r;function r(){return Et(this[wt][i](e.byteOffset,dt))}}ge.exports=Tt});var he=u(function($s,qe){"use strict";var me=require("@stdlib/assert-is-little-endian"),xt=require("@stdlib/complex-cmplx"),ye=y(),Ot={complex128:"float64",complex64:"float32",complex32:"float16"};function bt(e,i){return r;function r(){var t=this[ye][i](e.byteOffset,me),n=this[ye][i](e.byteOffset+e.byteLength/2,me);return xt(t,n,Ot[e.type])}}qe.exports=bt});var Ee=u(function(Xs,de){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=y();function At(e,i){return r;function r(){return this[St][i](e.byteOffset,It)}}de.exports=At});var Te=u(function(Ks,we){"use strict";var Ft=y();function Vt(e){return i;function i(){var r=this[Ft];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}we.exports=Vt});var Oe=u(function(Qs,xe){"use strict";var Nt=require("@stdlib/array-typed"),Pt=y();function Rt(e){return i;function i(){var r=this[Pt];return Nt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}xe.exports=Rt});var Ie=u(function(Zs,be){"use strict";var _t=y();function Lt(e){return i;function i(){var r,t,n,a;for(t=this[_t],r=t.byteOffset+e.byteOffset,n=[],a=0;a0?null:new TypeError(ea("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=ra});var hr=u(function(Tu,qr){"use strict";var ta=require("@stdlib/assert-is-string").isPrimitive,ia=require("@stdlib/string-format");function na(e,i){return ta(e)?null:new TypeError(ia("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=na});var Er=u(function(xu,dr){"use strict";var aa=require("@stdlib/assert-is-positive-integer").isPrimitive,sa=require("@stdlib/string-format");function ua(e,i){return aa(e)?null:new TypeError(sa("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=ua});var Tr=u(function(Ou,wr){"use strict";var oa=require("@stdlib/assert-is-boolean").isPrimitive,fa=require("@stdlib/string-format");function va(e,i){return oa(e)?null:new TypeError(fa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}wr.exports=va});var Or=u(function(bu,xr){"use strict";var la=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=la});var Sr=u(function(Iu,Ir){"use strict";var ca=require("@stdlib/array-base-assert-contains"),ga=require("@stdlib/array-base-join"),pa=require("@stdlib/string-format"),ma=V(),br=Or();function ya(e){return ca(br,e)||ma(e)?null:new TypeError(pa('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",ga(br,", "),e))}Ir.exports=ya});var Fr=u(function(Su,Ar){"use strict";var qa=require("@stdlib/array-base-assert-contains"),ha=require("@stdlib/array-base-join"),da=require("@stdlib/string-format");function Ea(e){return i;function i(r,t){return qa(e,r)?null:new TypeError(da('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ha(e,", "),r))}}Ar.exports=Ea});var Nr=u(function(Au,Vr){"use strict";function wa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=wa});var Rr=u(function(Fu,Pr){"use strict";var Ta=require("@stdlib/ndarray-base-bytes-per-element");function xa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Ta(e.type),e.length&&(i*=e.length),i}Pr.exports=xa});var Lr=u(function(Vu,_r){"use strict";var Oa=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Oa});var Dr=u(function(Nu,Br){"use strict";var ba={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=ba});var re=u(function(Pu,Mr){"use strict";var Ia=require("@stdlib/assert-has-property"),Sa=require("@stdlib/array-base-join"),Aa=require("@stdlib/utils-constant-function"),Fa=require("@stdlib/string-format"),Va=pr(),Na=V(),Pa=yr(),Ra=hr(),_a=Er(),Ur=Tr(),La=Sr(),Ba=Fr(),Da=Nr(),Ua=Rr(),Ca=Lr(),Ma=Dr(),Cr=["name","type"],ka={name:Pa,type:La,description:Ra,length:_a,enumerable:Ur,writable:Ur,default:Aa(null),castingMode:Ba(Ca)};function Ja(e,i){var r,t,n,a,s;for(r=Da(),s=0;si&&(i=r);return i}kr.exports=za});var Gr=u(function(_u,zr){"use strict";var Ga=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),ie=require("@stdlib/string-format"),Wa=P(),Ha=ee(),Ya=re(),$a=te();function Xa(e){var i,r,t,n,a,s,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(a=e[o-1],a.padding=t,ne(s)&&Qr(a.fields,t)),s.byteOffset=n,ne(s))for(p=0;pI&&(I=F);for(n="%"+I+"s",a="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&v.byteOffset===i[m-1].byteOffset)){for(m1?s=" (byte %u)":s="",c){for(o=" => union: %s",l=[],R=m+1;R[%u]",w.name,w.type,T%w.alignment)),R+=1;o=q(o,l.join(", "))}else o="";l=q(s+o,T%v.alignment),v.length?E=q(a,q("%s[%u]%s",v.type,gs(T/v.alignment),l)):E=q(a,q("%s%s",v.type,l)),f.push(q(p,O,h,E)),g+=1}for(T=0;T"}at.exports=ys});var ot=u(function(ku,ut){"use strict";var qs=require("@stdlib/assert-is-collection"),hs=require("@stdlib/assert-is-complex-like"),ds=require("@stdlib/assert-is-function"),Es=require("@stdlib/array-to-json"),ws=V();function Ts(e,i){var r,t,n,a;for(r={},a=0;a0){if(!Is(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,ue,b),I!==void 0){for(O=As(void 0,s.length),E={},v=0;v0?c=arguments[0]:c={},Us(this,s,c)}),d(l.prototype,"toJSON",function(){if(!(this instanceof l))throw new Error("invalid invocation. `this` is not a struct instance.");return Cs(this,s)}),l}lt.exports=Ms});var ks=ct();module.exports=ks; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8828372..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAwBA,IAAIC,GAAmB,QAAS,iCAAkC,EAC9DC,GAAiB,IAarB,SAASC,GAAWC,EAAKC,EAAS,CACjC,OAAOC,EAQP,SAASA,GAAS,CACjB,OAAO,KAAMJ,EAAe,EAAG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EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF5B,GAAe,KAAMS,EAAQmB,CAAK,CAC1C,CAAC,EAaDnD,EAAamC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOX,GAAa,KAAMQ,CAAO,CAClC,CAAC,EAEMG,CACR,CAKApC,GAAO,QAAU0B,KCpZjB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isPositiveInteger", "isDataView", "isObject", "CTOR_NAME", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "floor", "format", "FORMATS", "isFormat", "linearFormat", "struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "toString", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 98e208e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 982ac40..0000000 --- a/examples/union.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index 13eefe5..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 85d5c64..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b50a911 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as V}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.0-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.2-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import{isPrimitive as B}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var it="__@@##$$@@__struct_buffer__@@$$##@@__",at="Struct",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[it]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Ot,t)||yt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(Ot,", "),t))},description:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return B(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:Q(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,o(Et,", "),t))})};function St(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,A(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function _t(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,it,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=t[o-1]).padding=s,wt(a)&&It(i.fields,s)),a.byteOffset=r,wt(a))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport CTOR_NAME from './ctor_name.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","CTOR_NAME","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isPositiveInteger","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;skLAuBA,IAAIA,GAAiB,wCCDjBC,GAAY,SCAZC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM7B,KACC8B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5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KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OMzaF,SAAiByG,EAAQrC,GACxB,IAAI1F,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI9B,EAAQzF,IACE4C,MACTmB,EAAchC,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CNqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 29e0475..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 2f6b307..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - return Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index 34d39f9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 131d179..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index 58b3ad7..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var CTOR_NAME = require( './ctor_name.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - value.constructor.name === CTOR_NAME && - isPositiveInteger( value.constructor.byteLength ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5187fdd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,474 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, byteLength ); - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index e878339..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index e5fd433..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 3f0fa26..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var re; - var im; - - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index 5d0fbe2..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 278a3ad..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,150 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index f03a711..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear' -]; -var isFormat = contains( FORMATS ); - - -// FUNCTIONS // - -/** -* Serializes a `struct` instance to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = struct.constructor.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct, fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 74e3965..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,88 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -130,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9b66e26 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From b0a541f69a97acd920d71fbcf1529c589e77faf8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 11:31:31 +0000 Subject: [PATCH 09/84] Transform error messages --- lib/field_names.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index aa160c4..080c257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -114,7 +114,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -189,7 +189,7 @@ function factory( fields ) { view = new DataView( arg ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset ); @@ -207,7 +207,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index c0e0800..e878339 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 4a43231..e5fd433 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 2309f4b..3f0fa26 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 28082e8..5d0fbe2 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 6f1f0c6..278a3ad 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index b476cfa..f03a711 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -200,7 +200,7 @@ function linearFormat( struct, fields ) { function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -208,7 +208,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 9b11753..74e3965 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@stdlib/number-ctor": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From f6de2a105f105064aee92e06c6808dfb86d0fdae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 11:31:55 +0000 Subject: [PATCH 10/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b50a911..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as V}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.0-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.2-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import{isPrimitive as B}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var it="__@@##$$@@__struct_buffer__@@$$##@@__",at="Struct",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[it]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Ot,t)||yt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(Ot,", "),t))},description:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return B(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:Q(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,o(Et,", "),t))})};function St(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,A(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function _t(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,it,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=t[o-1]).padding=s,wt(a)&&It(i.fields,s)),a.byteOffset=r,wt(a))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport CTOR_NAME from './ctor_name.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tvalue.constructor.name === CTOR_NAME &&\n\t\tisPositiveInteger( value.constructor.byteLength ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","CTOR_NAME","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isPositiveInteger","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;skLAuBA,IAAIA,GAAiB,wCCDjBC,GAAY,SCAZC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAER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EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEnDqM,EAAkCI,EAAG3D,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CL+VauL,CAA0BxB,EAAOyB,UAAW7B,GAiBxDa,EAAaT,EAAOyB,UAAW,YAAY,WAE1C,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAOlB,OAAOmK,GAAevL,KAAMyJ,EALvBQ,UAAUvK,OAAS,EAChBuK,UAAW,GAEX,CAAA,EAGV,IAaCK,EAAaT,EAAOyB,UAAW,UAAU,WACxC,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OMzaF,SAAiByG,EAAQrC,GACxB,IAAI1F,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI9B,EAAQzF,IACE4C,MACTmB,EAAchC,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CNqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9b66e26..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7352889f8849c2592a02d6fe8b767f6ba32c19c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Jun 2025 11:32:38 +0000 Subject: [PATCH 11/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 62 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 135 - examples/union.js | 80 - examples/union_with_complex.js | 75 - examples/union_with_struct.js | 99 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/get_bigint.js | 56 - lib/get_boolean.js | 57 - lib/get_complex.js | 68 - lib/get_number.js | 56 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 474 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 98 - lib/set_boolean.js | 91 - lib/set_complex.js | 95 - lib/set_number.js | 101 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 150 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 224 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 95 files changed, 4863 insertions(+), 8094 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +293,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 69ae507..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(ks,ue){"use strict";var gt="__@@##$$@@__struct_buffer__@@$$##@@__";ue.exports=gt});var fe=u(function(Js,oe){"use strict";var pt="Struct";oe.exports=pt});var W=u(function(zs,ve){"use strict";var mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ve.exports=mt});var ce=u(function(Gs,le){"use strict";var yt=require("@stdlib/assert-is-little-endian"),qt=y();function ht(e,i){return r;function r(){return this[qt][i](e.byteOffset,yt)}}le.exports=ht});var pe=u(function(Ws,ge){"use strict";var dt=require("@stdlib/assert-is-little-endian"),Et=require("@stdlib/boolean-ctor"),wt=y();function Tt(e,i){return r;function r(){return Et(this[wt][i](e.byteOffset,dt))}}ge.exports=Tt});var he=u(function(Hs,qe){"use strict";var me=require("@stdlib/assert-is-little-endian"),xt=require("@stdlib/complex-cmplx"),ye=y(),Ot={complex128:"float64",complex64:"float32",complex32:"float16"};function bt(e,i){return r;function r(){var t=this[ye][i](e.byteOffset,me),n=this[ye][i](e.byteOffset+e.byteLength/2,me);return xt(t,n,Ot[e.type])}}qe.exports=bt});var Ee=u(function(Ys,de){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=y();function At(e,i){return r;function r(){return this[St][i](e.byteOffset,It)}}de.exports=At});var Te=u(function($s,we){"use strict";var Ft=y();function Vt(e){return i;function i(){var r=this[Ft];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}we.exports=Vt});var Oe=u(function(Xs,xe){"use strict";var Nt=require("@stdlib/array-typed"),Pt=y();function Rt(e){return i;function i(){var r=this[Pt];return Nt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}xe.exports=Rt});var Ie=u(function(Ks,be){"use strict";var _t=y();function Lt(e){return i;function i(){var r,t,n,a;for(t=this[_t],r=t.byteOffset+e.byteOffset,n=[],a=0;a0?null:new TypeError(Zn("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=jn});var hr=u(function(Eu,qr){"use strict";var ea=require("@stdlib/assert-is-string").isPrimitive,ra=require("@stdlib/string-format");function ta(e,i){return ea(e)?null:new TypeError(ra("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=ta});var Er=u(function(wu,dr){"use strict";var ia=require("@stdlib/assert-is-positive-integer").isPrimitive,na=require("@stdlib/string-format");function aa(e,i){return ia(e)?null:new TypeError(na("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=aa});var Tr=u(function(Tu,wr){"use strict";var sa=require("@stdlib/assert-is-boolean").isPrimitive,ua=require("@stdlib/string-format");function oa(e,i){return sa(e)?null:new TypeError(ua("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}wr.exports=oa});var Or=u(function(xu,xr){"use strict";var fa=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=fa});var Sr=u(function(Ou,Ir){"use strict";var va=require("@stdlib/array-base-assert-contains"),la=require("@stdlib/array-base-join"),ca=require("@stdlib/string-format"),ga=V(),br=Or();function pa(e){return va(br,e)||ga(e)?null:new TypeError(ca('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",la(br,", "),e))}Ir.exports=pa});var Fr=u(function(bu,Ar){"use strict";var ma=require("@stdlib/array-base-assert-contains"),ya=require("@stdlib/array-base-join"),qa=require("@stdlib/string-format");function ha(e){return i;function i(r,t){return ma(e,r)?null:new TypeError(qa('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ya(e,", "),r))}}Ar.exports=ha});var Nr=u(function(Iu,Vr){"use strict";function da(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=da});var Rr=u(function(Su,Pr){"use strict";var Ea=require("@stdlib/ndarray-base-bytes-per-element");function wa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Ea(e.type),e.length&&(i*=e.length),i}Pr.exports=wa});var Lr=u(function(Au,_r){"use strict";var Ta=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Ta});var Dr=u(function(Fu,Br){"use strict";var xa={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=xa});var ee=u(function(Vu,Mr){"use strict";var Oa=require("@stdlib/assert-has-property"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/utils-constant-function"),Sa=require("@stdlib/string-format"),Aa=pr(),Fa=V(),Va=yr(),Na=hr(),Pa=Er(),Ur=Tr(),Ra=Sr(),_a=Fr(),La=Nr(),Ba=Rr(),Da=Lr(),Ua=Dr(),Cr=["name","type"],Ca={name:Va,type:Ra,description:Na,length:Pa,enumerable:Ur,writable:Ur,default:Ia(null),castingMode:_a(Da)};function Ma(e,i){var r,t,n,a,s;for(r=La(),s=0;si&&(i=r);return i}kr.exports=ka});var Gr=u(function(Pu,zr){"use strict";var Ja=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),te=require("@stdlib/string-format"),za=P(),Ga=j(),Wa=ee(),Ha=re();function Ya(e){var i,r,t,n,a,s,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(a=e[o-1],a.padding=t,ie(s)&&Qr(a.fields,t)),s.byteOffset=n,ie(s))for(p=0;pI&&(I=F);for(n="%"+I+"s",a="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&v.byteOffset===i[m-1].byteOffset)){for(m1?s=" (byte %u)":s="",c){for(o=" => union: %s",l=[],R=m+1;R[%u]",w.name,w.type,T%w.alignment)),R+=1;o=q(o,l.join(", "))}else o="";l=q(s+o,T%v.alignment),v.length?E=q(a,q("%s[%u]%s",v.type,ls(T/v.alignment),l)):E=q(a,q("%s%s",v.type,l)),f.push(q(p,O,h,E)),g+=1}for(T=0;T"}at.exports=ps});var ot=u(function(Cu,ut){"use strict";var ms=require("@stdlib/assert-is-collection"),ys=require("@stdlib/assert-is-complex-like"),qs=require("@stdlib/assert-is-function"),hs=require("@stdlib/array-to-json"),ds=V();function Es(e,i){var r,t,n,a;for(r={},a=0;a0){if(!Os(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,se,b),I!==void 0){for(O=Is(void 0,s.length),E={},v=0;v0?c=arguments[0]:c={},Bs(this,s,c)}),d(l.prototype,"toJSON",function(){if(!(this instanceof l))throw new Error("invalid invocation. `this` is not a struct instance.");return Ds(this,s)}),l}lt.exports=Us});var Cs=ct();module.exports=Cs; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ef47bc3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAU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AM,CAAE,EAC/BC,EAAM,EACV,MAAM,IAAI,UAAWrC,EAAQ,oFAAqFL,GAAMoB,EAAa,IAAK,EAAGqB,CAAK,CAAE,EAErJ,OAAOhB,EAAQiB,CAAI,EAAE,WACtB,CAAC,EAcDjD,EAAamC,EAAQ,WAAY,SAAmBQ,EAAM,CACzD,GAAK,CAAC3B,GAAU2B,CAAI,EACnB,MAAM,IAAI,UAAW/B,EAAQ,6EAA8E+B,CAAI,CAAE,EAElH,OAAOA,EAAK9B,EAAe,EAAE,MAC9B,CAAC,EAcDb,EAAamC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIO,EACJ,GAAK,CAAClC,GAAU2B,CAAI,EACnB,MAAM,IAAI,UAAW/B,EAAQ,6EAA8E+B,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAK9B,EAAe,EACnB,IAAIF,EAAUuC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYhB,GAA0BoB,EAAO,UAAWH,CAAO,EAiB/DhC,EAAamC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF5B,GAAe,KAAMS,EAAQmB,CAAK,CAC1C,CAAC,EAaDnD,EAAamC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOX,GAAa,KAAMQ,CAAO,CAClC,CAAC,EAEMG,CACR,CAKApC,GAAO,QAAU0B,KCpZjB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "floor", "format", "FORMATS", "isFormat", "linearFormat", "struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "toString", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 98e208e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 982ac40..0000000 --- a/examples/union.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index 13eefe5..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 85d5c64..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..093d02e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import ee,{factory as te}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import ne from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import se from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import re from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ie from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import ae from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import oe from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var le="__@@##$$@@__struct_buffer__@@$$##@@__",fe={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var de={complex128:"float64",complex64:"float32",complex32:"float16"};function me(e){if(e.length)return e.isStructType?function(e){return function(){var t,n,s,r;for(t=(n=this[le]).byteOffset+e.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",t,e))},type:function(e){return ee(Te,e)||ve(e)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(Te,", "),e))},description:function(e,t){return X(e)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",t,e))},length:function(e,t){return Y(e)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",t,e))},enumerable:Ee,writable:Ee,default:W(null),castingMode:(Ve=["none","safe","mostly-safe","same-kind","unsafe"],function(e,t){return ee(Ve,e)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,o(Ve,", "),e))})};function Ue(e,t){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;lt&&(t=n);return t}function Je(e){var t,n,s,r,o,l,f;if(0===(t=e.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===t[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,A(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function Ae(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(e){var t,n,s,r;for(t=[],r=0;r0){if(!i(t))throw new TypeError(u("null3L",t));h=t}if(e(this,le,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=e[o-1]).padding=s,Oe(a)&&Ne(i.fields,s)),a.byteOffset=r,Oe(a))for(l=0;l0?arguments[0]:{})})),e(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(e,t){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;uzLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAKC,YAAaP,EAAKQ,OAAQT,EAAQH,EAAIa,aAC7DV,GAAUH,EAAIQ,WAEf,OAAOH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/B+B,EAAI+F,GADJP,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 29e0475..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 2f6b307..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - return Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index 34d39f9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 131d179..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index b8ce685..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 080c257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,474 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, byteLength ); - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index e878339..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index e5fd433..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 3f0fa26..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var re; - var im; - - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index 5d0fbe2..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 278a3ad..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,150 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index f03a711..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear' -]; -var isFormat = contains( FORMATS ); - - -// FUNCTIONS // - -/** -* Serializes a `struct` instance to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = struct.constructor.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct, fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 74e3965..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,88 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -130,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c4204dd --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 1a4e565e6b5b07bebddf2c31657e64a884d65691 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Jun 2025 11:15:09 +0000 Subject: [PATCH 12/84] Transform error messages --- lib/field_names.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index aa160c4..080c257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -114,7 +114,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -189,7 +189,7 @@ function factory( fields ) { view = new DataView( arg ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset ); @@ -207,7 +207,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index c0e0800..e878339 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 4a43231..e5fd433 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 2309f4b..3f0fa26 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 28082e8..5d0fbe2 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 6f1f0c6..278a3ad 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index b476cfa..f03a711 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -200,7 +200,7 @@ function linearFormat( struct, fields ) { function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -208,7 +208,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 9b11753..74e3965 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@stdlib/number-ctor": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From ed928ae0a97d4c73f9c65b0583043084c68d70a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Jun 2025 11:15:29 +0000 Subject: [PATCH 13/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 093d02e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import ee,{factory as te}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import ne from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import se from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import re from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ie from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import ae from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import oe from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var le="__@@##$$@@__struct_buffer__@@$$##@@__",fe={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var de={complex128:"float64",complex64:"float32",complex32:"float16"};function me(e){if(e.length)return e.isStructType?function(e){return function(){var t,n,s,r;for(t=(n=this[le]).byteOffset+e.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",t,e))},type:function(e){return ee(Te,e)||ve(e)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(Te,", "),e))},description:function(e,t){return X(e)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",t,e))},length:function(e,t){return Y(e)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",t,e))},enumerable:Ee,writable:Ee,default:W(null),castingMode:(Ve=["none","safe","mostly-safe","same-kind","unsafe"],function(e,t){return ee(Ve,e)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,o(Ve,", "),e))})};function Ue(e,t){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;lt&&(t=n);return t}function Je(e){var t,n,s,r,o,l,f;if(0===(t=e.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===t[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,A(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function Ae(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(e){var t,n,s,r;for(t=[],r=0;r0){if(!i(t))throw new TypeError(u("null3L",t));h=t}if(e(this,le,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=e[o-1]).padding=s,Oe(a)&&Ne(i.fields,s)),a.byteOffset=r,Oe(a))for(l=0;l0?arguments[0]:{})})),e(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(e,t){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;uzLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,I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AAmCH,EAAG3D,EAAE3E,KAAMpE,EAAKC,GAEnDqM,EAAkCI,EAAG3D,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CN+VauL,CAA0BxB,EAAOyB,UAAW7B,GAiBxDa,EAAaT,EAAOyB,UAAW,YAAY,WAE1C,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAOlB,OAAOmK,GAAevL,KAAMyJ,EALvBQ,UAAUvK,OAAS,EAChBuK,UAAW,GAEX,CAAA,EAGV,IAaCK,EAAaT,EAAOyB,UAAW,UAAU,WACxC,KAAQtL,gBAAgB6J,GACvB,MAAM,IAAIzI,MAAO,wDAElB,OOzaF,SAAiByG,EAAQtC,GACxB,IAAIzF,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c4204dd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9d17667dc7b364a10afb66f34c5c44924c2eb950 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Jun 2025 11:16:24 +0000 Subject: [PATCH 14/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 135 - examples/union.js | 80 - examples/union_with_complex.js | 75 - examples/union_with_struct.js | 99 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/get_bigint.js | 56 - lib/get_boolean.js | 57 - lib/get_complex.js | 68 - lib/get_number.js | 56 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 474 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 98 - lib/set_boolean.js | 91 - lib/set_complex.js | 95 - lib/set_number.js | 101 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 150 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 224 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 95 files changed, 4863 insertions(+), 8095 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 69ae507..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(ks,ue){"use strict";var gt="__@@##$$@@__struct_buffer__@@$$##@@__";ue.exports=gt});var fe=u(function(Js,oe){"use strict";var pt="Struct";oe.exports=pt});var W=u(function(zs,ve){"use strict";var mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ve.exports=mt});var ce=u(function(Gs,le){"use strict";var yt=require("@stdlib/assert-is-little-endian"),qt=y();function ht(e,i){return r;function r(){return this[qt][i](e.byteOffset,yt)}}le.exports=ht});var pe=u(function(Ws,ge){"use strict";var dt=require("@stdlib/assert-is-little-endian"),Et=require("@stdlib/boolean-ctor"),wt=y();function Tt(e,i){return r;function r(){return Et(this[wt][i](e.byteOffset,dt))}}ge.exports=Tt});var he=u(function(Hs,qe){"use strict";var me=require("@stdlib/assert-is-little-endian"),xt=require("@stdlib/complex-cmplx"),ye=y(),Ot={complex128:"float64",complex64:"float32",complex32:"float16"};function bt(e,i){return r;function r(){var t=this[ye][i](e.byteOffset,me),n=this[ye][i](e.byteOffset+e.byteLength/2,me);return xt(t,n,Ot[e.type])}}qe.exports=bt});var Ee=u(function(Ys,de){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=y();function At(e,i){return r;function r(){return this[St][i](e.byteOffset,It)}}de.exports=At});var Te=u(function($s,we){"use strict";var Ft=y();function Vt(e){return i;function i(){var r=this[Ft];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}we.exports=Vt});var Oe=u(function(Xs,xe){"use strict";var Nt=require("@stdlib/array-typed"),Pt=y();function Rt(e){return i;function i(){var r=this[Pt];return Nt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}xe.exports=Rt});var Ie=u(function(Ks,be){"use strict";var _t=y();function Lt(e){return i;function i(){var r,t,n,a;for(t=this[_t],r=t.byteOffset+e.byteOffset,n=[],a=0;a0?null:new TypeError(Zn("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=jn});var hr=u(function(Eu,qr){"use strict";var ea=require("@stdlib/assert-is-string").isPrimitive,ra=require("@stdlib/string-format");function ta(e,i){return ea(e)?null:new TypeError(ra("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=ta});var Er=u(function(wu,dr){"use strict";var ia=require("@stdlib/assert-is-positive-integer").isPrimitive,na=require("@stdlib/string-format");function aa(e,i){return ia(e)?null:new TypeError(na("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=aa});var Tr=u(function(Tu,wr){"use strict";var sa=require("@stdlib/assert-is-boolean").isPrimitive,ua=require("@stdlib/string-format");function oa(e,i){return sa(e)?null:new TypeError(ua("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}wr.exports=oa});var Or=u(function(xu,xr){"use strict";var fa=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=fa});var Sr=u(function(Ou,Ir){"use strict";var va=require("@stdlib/array-base-assert-contains"),la=require("@stdlib/array-base-join"),ca=require("@stdlib/string-format"),ga=V(),br=Or();function pa(e){return va(br,e)||ga(e)?null:new TypeError(ca('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",la(br,", "),e))}Ir.exports=pa});var Fr=u(function(bu,Ar){"use strict";var ma=require("@stdlib/array-base-assert-contains"),ya=require("@stdlib/array-base-join"),qa=require("@stdlib/string-format");function ha(e){return i;function i(r,t){return ma(e,r)?null:new TypeError(qa('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ya(e,", "),r))}}Ar.exports=ha});var Nr=u(function(Iu,Vr){"use strict";function da(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=da});var Rr=u(function(Su,Pr){"use strict";var Ea=require("@stdlib/ndarray-base-bytes-per-element");function wa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Ea(e.type),e.length&&(i*=e.length),i}Pr.exports=wa});var Lr=u(function(Au,_r){"use strict";var Ta=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Ta});var Dr=u(function(Fu,Br){"use strict";var xa={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=xa});var ee=u(function(Vu,Mr){"use strict";var Oa=require("@stdlib/assert-has-property"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/utils-constant-function"),Sa=require("@stdlib/string-format"),Aa=pr(),Fa=V(),Va=yr(),Na=hr(),Pa=Er(),Ur=Tr(),Ra=Sr(),_a=Fr(),La=Nr(),Ba=Rr(),Da=Lr(),Ua=Dr(),Cr=["name","type"],Ca={name:Va,type:Ra,description:Na,length:Pa,enumerable:Ur,writable:Ur,default:Ia(null),castingMode:_a(Da)};function Ma(e,i){var r,t,n,a,s;for(r=La(),s=0;si&&(i=r);return i}kr.exports=ka});var Gr=u(function(Pu,zr){"use strict";var Ja=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),te=require("@stdlib/string-format"),za=P(),Ga=j(),Wa=ee(),Ha=re();function Ya(e){var i,r,t,n,a,s,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(a=e[o-1],a.padding=t,ie(s)&&Qr(a.fields,t)),s.byteOffset=n,ie(s))for(p=0;pI&&(I=F);for(n="%"+I+"s",a="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&v.byteOffset===i[m-1].byteOffset)){for(m1?s=" (byte %u)":s="",c){for(o=" => union: %s",l=[],R=m+1;R[%u]",w.name,w.type,T%w.alignment)),R+=1;o=q(o,l.join(", "))}else o="";l=q(s+o,T%v.alignment),v.length?E=q(a,q("%s[%u]%s",v.type,ls(T/v.alignment),l)):E=q(a,q("%s%s",v.type,l)),f.push(q(p,O,h,E)),g+=1}for(T=0;T"}at.exports=ps});var ot=u(function(Cu,ut){"use strict";var ms=require("@stdlib/assert-is-collection"),ys=require("@stdlib/assert-is-complex-like"),qs=require("@stdlib/assert-is-function"),hs=require("@stdlib/array-to-json"),ds=V();function Es(e,i){var r,t,n,a;for(r={},a=0;a0){if(!Os(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,se,b),I!==void 0){for(O=Is(void 0,s.length),E={},v=0;v0?c=arguments[0]:c={},Bs(this,s,c)}),d(l.prototype,"toJSON",function(){if(!(this instanceof l))throw new Error("invalid invocation. `this` is not a struct instance.");return Ds(this,s)}),l}lt.exports=Us});var Cs=ct();module.exports=Cs; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ef47bc3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO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qB,EAAM,CAAE,EAC/BC,EAAM,EACV,MAAM,IAAI,UAAWrC,EAAQ,oFAAqFL,GAAMoB,EAAa,IAAK,EAAGqB,CAAK,CAAE,EAErJ,OAAOhB,EAAQiB,CAAI,EAAE,WACtB,CAAC,EAcDjD,EAAamC,EAAQ,WAAY,SAAmBQ,EAAM,CACzD,GAAK,CAAC3B,GAAU2B,CAAI,EACnB,MAAM,IAAI,UAAW/B,EAAQ,6EAA8E+B,CAAI,CAAE,EAElH,OAAOA,EAAK9B,EAAe,EAAE,MAC9B,CAAC,EAcDb,EAAamC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIO,EACJ,GAAK,CAAClC,GAAU2B,CAAI,EACnB,MAAM,IAAI,UAAW/B,EAAQ,6EAA8E+B,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAK9B,EAAe,EACnB,IAAIF,EAAUuC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYhB,GAA0BoB,EAAO,UAAWH,CAAO,EAiB/DhC,EAAamC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF5B,GAAe,KAAMS,EAAQmB,CAAK,CAC1C,CAAC,EAaDnD,EAAamC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOX,GAAa,KAAMQ,CAAO,CAClC,CAAC,EAEMG,CACR,CAKApC,GAAO,QAAU0B,KCpZjB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "floor", "format", "FORMATS", "isFormat", "linearFormat", "struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "toString", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 98e208e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 982ac40..0000000 --- a/examples/union.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index 13eefe5..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 85d5c64..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d69d41 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as J}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as _}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as A}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import nt,{factory as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var dt="__@@##$$@@__struct_buffer__@@$$##@@__",mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ut={complex128:"float64",complex64:"float32",complex32:"float16"};function pt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[dt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return nt(St,t)||wt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(St,", "),t))},description:function(t,e){return tt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return et(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Vt,writable:Vt,default:Z(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return nt(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,o(Lt,", "),t))})};function Jt(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Mt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,R(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function Bt(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,dt,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=t[o-1]).padding=s,Tt(a)&&Pt(i.fields,s)),a.byteOffset=r,Tt(a))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;khMAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/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GACvB,MAAM,IAAIzI,MAAO,wDAElB,OOzaF,SAAiByG,EAAQtC,GACxB,IAAIzF,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B+B,EAAI+F,GADJP,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAI0J,GAAiB1J,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAO2J,GAAY3J,EAAE4J,WAD/C5J,EAAIA,EAAE4J,UAIP5L,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqZS6L,CAAa3L,KAAMyJ,EAC5B,IAEQI,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 29e0475..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 2f6b307..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - return Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index 34d39f9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var re = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 131d179..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - return this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index b8ce685..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 080c257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,474 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, byteLength ); - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index e878339..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index e5fd433..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 3f0fa26..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var re; - var im; - - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index 5d0fbe2..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 278a3ad..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,150 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index f03a711..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear' -]; -var isFormat = contains( FORMATS ); - - -// FUNCTIONS // - -/** -* Serializes a `struct` instance to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = struct.constructor.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct, fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 74e3965..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,88 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -130,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1216912 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 401640d6063d4bb440a34b41e6f8e479428c1cb2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 19 Jun 2025 10:16:19 +0000 Subject: [PATCH 15/84] Transform error messages --- lib/field_names.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 1a7528d..259cae1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -115,7 +115,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -190,7 +190,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -208,7 +208,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 41bd4a1..7420006 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index b476cfa..f03a711 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -200,7 +200,7 @@ function linearFormat( struct, fields ) { function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -208,7 +208,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 9b11753..74e3965 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@stdlib/number-ctor": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From ef1523681a0e79317aed5cec63155be748c0cf94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 19 Jun 2025 10:16:37 +0000 Subject: [PATCH 16/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d69d41..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as J}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.2.2-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as _}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as A}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import nt,{factory as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var dt="__@@##$$@@__struct_buffer__@@$$##@@__",mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ut={complex128:"float64",complex64:"float32",complex32:"float16"};function pt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[dt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return nt(St,t)||wt(t)?null:new TypeError(u('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",o(St,", "),t))},description:function(t,e){return tt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return et(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Vt,writable:Vt,default:Z(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return nt(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,o(Lt,", "),t))})};function Jt(t,e){var n,s,r,i,l;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Mt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,x%v.alignment),c=v.length?u(r,u("%s[%u]%s",v.type,R(x/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,g,c)),m+=1}for(x=0;x"}function Bt(h){var y,b,v,j,w,x,O,E;if(!s(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(u("null3L",e));h=e}if(t(this,dt,c),void 0!==h){for(f=l(void 0,x.length),g={},E=0;E0&&((i=t[o-1]).padding=s,Tt(a)&&Pt(i.fields,s)),a.byteOffset=r,Tt(a))for(l=0;l0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\treturn this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\treturn Boolean( this[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = typedarray( this[ PRIVATE_BUFFER ].buffer, obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tthis[ PRIVATE_BUFFER ][ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, byteLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","ArrayBuffer","setReadOnly","filled","call","min","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;khMAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ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stats.html deleted file mode 100644 index 1216912..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 333cc375cef5255727c1ff56950629e92d3019d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 19 Jun 2025 10:17:14 +0000 Subject: [PATCH 17/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 71 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 135 - examples/union.js | 80 - examples/union_with_complex.js | 75 - examples/union_with_struct.js | 99 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 475 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 224 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 95 files changed, 4863 insertions(+), 8116 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 752e867..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(Js,ue){"use strict";var lt="__@@##$$@@__struct_buffer__@@$$##@@__";ue.exports=lt});var fe=u(function(zs,oe){"use strict";var ct="Struct";oe.exports=ct});var W=u(function(Gs,ve){"use strict";var gt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ve.exports=gt});var ce=u(function(Ws,le){"use strict";var pt=require("@stdlib/assert-is-little-endian"),mt=y();function yt(e,i){return t;function t(){var r=this[mt];return r[i](e.byteOffset,pt)}}le.exports=yt});var pe=u(function(Hs,ge){"use strict";var qt=require("@stdlib/assert-is-little-endian"),ht=require("@stdlib/boolean-ctor"),dt=y();function wt(e,i){return t;function t(){var r=this[dt];return ht(r[i](e.byteOffset,qt))}}ge.exports=wt});var qe=u(function(Ys,ye){"use strict";var me=require("@stdlib/assert-is-little-endian"),Et=require("@stdlib/complex-cmplx"),Tt=y(),xt={complex128:"float64",complex64:"float32",complex32:"float16"};function Ot(e,i){return t;function t(){var r=this[Tt],s=r[i](e.byteOffset,me),n=r[i](e.byteOffset+e.byteLength/2,me);return Et(s,n,xt[e.type])}}ye.exports=Ot});var de=u(function($s,he){"use strict";var bt=require("@stdlib/assert-is-little-endian"),It=y();function St(e,i){return t;function t(){var r=this[It];return r[i](e.byteOffset,bt)}}he.exports=St});var Ee=u(function(Xs,we){"use strict";var At=y();function Ft(e){return i;function i(){var t=this[At];return new e.type.constructor(t.buffer,t.byteOffset+e.byteOffset,e.byteLength)}}we.exports=Ft});var xe=u(function(Ks,Te){"use strict";var Vt=require("@stdlib/array-typed"),Nt=y();function Pt(e){return i;function i(){var t=this[Nt];return Vt(t.buffer,t.byteOffset+e.byteOffset,e.length,e.type)}}Te.exports=Pt});var be=u(function(Qs,Oe){"use strict";var Rt=y();function _t(e){return i;function i(){var t,r,s,n;for(r=this[Rt],t=r.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(Zn("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}gr.exports=jn});var yr=u(function(Eu,mr){"use strict";var ea=require("@stdlib/assert-is-string").isPrimitive,ra=require("@stdlib/string-format");function ta(e,i){return ea(e)?null:new TypeError(ra("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}mr.exports=ta});var hr=u(function(Tu,qr){"use strict";var ia=require("@stdlib/assert-is-positive-integer").isPrimitive,na=require("@stdlib/string-format");function aa(e,i){return ia(e)?null:new TypeError(na("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}qr.exports=aa});var wr=u(function(xu,dr){"use strict";var sa=require("@stdlib/assert-is-boolean").isPrimitive,ua=require("@stdlib/string-format");function oa(e,i){return sa(e)?null:new TypeError(ua("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}dr.exports=oa});var Tr=u(function(Ou,Er){"use strict";var fa=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Er.exports=fa});var br=u(function(bu,Or){"use strict";var va=require("@stdlib/array-base-assert-contains"),la=require("@stdlib/array-base-join"),ca=require("@stdlib/string-format"),ga=V(),xr=Tr();function pa(e){return va(xr,e)||ga(e)?null:new TypeError(ca('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",la(xr,", "),e))}Or.exports=pa});var Sr=u(function(Iu,Ir){"use strict";var ma=require("@stdlib/array-base-assert-contains"),ya=require("@stdlib/array-base-join"),qa=require("@stdlib/string-format");function ha(e){return i;function i(t,r){return ma(e,t)?null:new TypeError(qa('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',r,ya(e,", "),t))}}Ir.exports=ha});var Fr=u(function(Su,Ar){"use strict";function da(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Ar.exports=da});var Nr=u(function(Au,Vr){"use strict";var wa=require("@stdlib/ndarray-base-bytes-per-element");function Ea(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=wa(e.type),e.length&&(i*=e.length),i}Vr.exports=Ea});var Rr=u(function(Fu,Pr){"use strict";var Ta=["none","safe","mostly-safe","same-kind","unsafe"];Pr.exports=Ta});var Lr=u(function(Vu,_r){"use strict";var xa={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};_r.exports=xa});var ee=u(function(Nu,Ur){"use strict";var Oa=require("@stdlib/assert-has-property"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/utils-constant-function"),Sa=require("@stdlib/string-format"),Aa=cr(),Fa=V(),Va=pr(),Na=yr(),Pa=hr(),Br=wr(),Ra=br(),_a=Sr(),La=Fr(),Ba=Nr(),Da=Rr(),Ua=Lr(),Dr=["name","type"],Ca={name:Va,type:Ra,description:Na,length:Pa,enumerable:Br,writable:Br,default:Ia(null),castingMode:_a(Da)};function Ma(e,i){var t,r,s,n,a;for(t=La(),a=0;ai&&(i=t);return i}Cr.exports=ka});var Jr=u(function(Ru,kr){"use strict";var Ja=require("@stdlib/assert-is-object"),Mr=require("@stdlib/assert-has-property"),te=require("@stdlib/string-format"),za=P(),Ga=j(),Wa=ee(),Ha=re();function Ya(e){var i,t,r,s,n,a,o;if(i=e.fields,i.length===0)return null;for(r=[],o=0;o0&&(n=e[o-1],n.padding=r,ie(a)&&Xr(n.fields,r)),a.byteOffset=s,ie(a))for(p=0;pI&&(I=F);for(s="%"+I+"s",n="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&v.byteOffset===i[m-1].byteOffset)){for(m1?a=" (byte %u)":a="",c){for(o=" => union: %s",l=[],R=m+1;R[%u]",E.name,E.type,T%E.alignment)),R+=1;o=q(o,l.join(", "))}else o="";l=q(a+o,T%v.alignment),v.length?w=q(n,q("%s[%u]%s",v.type,ls(T/v.alignment),l)):w=q(n,q("%s%s",v.type,l)),f.push(q(p,O,h,w)),g+=1}for(T=0;T"}it.exports=ps});var st=u(function(Mu,at){"use strict";var ms=require("@stdlib/assert-is-collection"),ys=require("@stdlib/assert-is-complex-like"),qs=require("@stdlib/assert-is-function"),hs=require("@stdlib/array-to-json"),ds=V();function ws(e,i){var t,r,s,n;for(t={},n=0;n0){if(!Os(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,se,b),I!==void 0){for(O=Ss(void 0,a.length),w={},v=0;v0?c=arguments[0]:c={},Ds(this,a,c)}),d(l.prototype,"toJSON",function(){if(!(this instanceof l))throw new Error("invalid invocation. `this` is not a struct instance.");return Us(this,a)}),l}ft.exports=Cs});var Ms=vt();module.exports=Ms; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 80eefc6..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCx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ClC,GAAU2B,CAAI,EACnB,MAAM,IAAI,UAAW/B,EAAQ,6EAA8E+B,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAK9B,EAAe,EACnB,IAAIF,EAAUuC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYhB,GAA0BoB,EAAO,UAAWH,CAAO,EAiB/DjC,EAAaoC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF5B,GAAe,KAAMS,EAAQmB,CAAK,CAC1C,CAAC,EAaDpD,EAAaoC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOX,GAAa,KAAMQ,CAAO,CAClC,CAAC,EAEMG,CACR,CAKArC,GAAO,QAAU2B,KCrZjB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "floor", "format", "FORMATS", "isFormat", "linearFormat", "struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "toString", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 98e208e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 982ac40..0000000 --- a/examples/union.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index 13eefe5..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 85d5c64..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ca271ed --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as V}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Y,{factory as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import ee from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import te from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ne from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import se from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import re from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ie="__@@##$$@@__struct_buffer__@@$$##@@__",ae={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var oe={complex128:"float64",complex64:"float32",complex32:"float16"};function le(e){if(e.length)return e.isStructType?function(e){return function(){var t,n,s,r;for(t=(n=this[ie]).byteOffset+e.byteOffset,s=[],r=0;r0?null:new TypeError(p("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",t,e))},type:function(e){return Y(xe,e)||he(e)?null:new TypeError(p('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",l(xe,", "),e))},description:function(e,t){return W(e)?null:new TypeError(p("invalid argument. `%s` field must be a string. Value: `%s`.",t,e))},length:function(e,t){return X(e)?null:new TypeError(p("invalid argument. `%s` field must be a positive integer. Value: `%s`.",t,e))},enumerable:we,writable:we,default:Q(null),castingMode:(Oe=["none","safe","mostly-safe","same-kind","unsafe"],function(e,t){return Y(Oe,e)?null:new TypeError(p('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,l(Oe,", "),e))})};function Se(e,t){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;ot&&(t=n);return t}function Fe(e){var t,n,s,r,o,l,f;if(0===(t=e.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===t[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=p(a,l.join(", "))}else a="";l=p(i+a,x%v.alignment),c=v.length?p(r,p("%s[%u]%s",v.type,A(x/v.alignment),l)):p(r,p("%s%s",v.type,l)),f.push(p(o,u,g,c)),m+=1}for(x=0;x"}function Me(y){var b,v,j,w,x,O,E,T;if(!s(y))throw new TypeError(p("null2O",y));if(E=function(e){var t,n,s,r;for(t=[],r=0;r0){if(!i(t))throw new TypeError(p("null3L",t));y=t}if(e(this,ie,h),void 0!==y){for(d=f(void 0,O.length),c={},T=0;T0&&((i=e[l-1]).padding=s,je(a)&&Ue(i.fields,s)),a.byteOffset=r,je(a))for(f=0;f0?arguments[0]:{})})),e(V.prototype,"toJSON",(function(){if(!(this instanceof V))throw new Error("invalid invocation. `this` is not a struct instance.");return function(e,t){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;o/KAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO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index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index b8ce685..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 259cae1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,475 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 7420006..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index f03a711..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear' -]; -var isFormat = contains( FORMATS ); - - -// FUNCTIONS // - -/** -* Serializes a `struct` instance to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = struct.constructor.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct, fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 74e3965..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,88 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -130,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6468f4c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 33cebc78cc520c8f4d2b068b6632c993db17375f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 03:52:47 +0000 Subject: [PATCH 18/84] Transform error messages --- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 24 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index 98552eb..c6191c3 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index af9cccf..f991b05 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 2c24338..4b85892 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 41bd4a1..7420006 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 974100c..e0c3b81 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 639c30d2b62543fb1bcf08a2b6c9ff407b0607d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 03:53:04 +0000 Subject: [PATCH 19/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ca271ed..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as V}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Y,{factory as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import ee from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import te from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import ne from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import se from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import re from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ie="__@@##$$@@__struct_buffer__@@$$##@@__",ae={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var oe={complex128:"float64",complex64:"float32",complex32:"float16"};function le(e){if(e.length)return e.isStructType?function(e){return function(){var t,n,s,r;for(t=(n=this[ie]).byteOffset+e.byteOffset,s=[],r=0;r0?null:new TypeError(p("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",t,e))},type:function(e){return Y(xe,e)||he(e)?null:new TypeError(p('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",l(xe,", "),e))},description:function(e,t){return W(e)?null:new TypeError(p("invalid argument. `%s` field must be a string. Value: `%s`.",t,e))},length:function(e,t){return X(e)?null:new TypeError(p("invalid argument. `%s` field must be a positive integer. Value: `%s`.",t,e))},enumerable:we,writable:we,default:Q(null),castingMode:(Oe=["none","safe","mostly-safe","same-kind","unsafe"],function(e,t){return Y(Oe,e)?null:new TypeError(p('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,l(Oe,", "),e))})};function Se(e,t){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;ot&&(t=n);return t}function Fe(e){var t,n,s,r,o,l,f;if(0===(t=e.fields).length)return null;for(s=[],f=0;fh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===t[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(a=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;a=p(a,l.join(", "))}else a="";l=p(i+a,x%v.alignment),c=v.length?p(r,p("%s[%u]%s",v.type,A(x/v.alignment),l)):p(r,p("%s%s",v.type,l)),f.push(p(o,u,g,c)),m+=1}for(x=0;x"}function Me(y){var b,v,j,w,x,O,E,T;if(!s(y))throw new TypeError(p("null2O",y));if(E=function(e){var t,n,s,r;for(t=[],r=0;r0){if(!i(t))throw new TypeError(p("null3L",t));y=t}if(e(this,ie,h),void 0!==y){for(d=f(void 0,O.length),c={},T=0;T0&&((i=e[l-1]).padding=s,je(a)&&Ue(i.fields,s)),a.byteOffset=r,je(a))for(f=0;f0?arguments[0]:{})})),e(V.prototype,"toJSON",(function(){if(!(this instanceof V))throw new Error("invalid invocation. `this` is not a struct instance.");return function(e,t){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear'\n];\nvar isFormat = contains( FORMATS );\n\n\n// FUNCTIONS //\n\n/**\n* Serializes a `struct` instance to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = struct.constructor.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct, fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","N","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","Struct","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;o/KAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,Y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,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6468f4c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e238118b72087d0015af89606ef872626290c9ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 03:53:48 +0000 Subject: [PATCH 20/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 130 - lib/format_linear.js | 175 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 490 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 98 files changed, 4863 insertions(+), 8407 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11b01cd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(ru,fe){"use strict";var ht="__@@##$$@@__struct_buffer__@@$$##@@__";fe.exports=ht});var le=u(function(tu,ve){"use strict";var dt="Struct";ve.exports=dt});var W=u(function(iu,ce){"use strict";var wt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ce.exports=wt});var pe=u(function(nu,ge){"use strict";var Et=require("@stdlib/assert-is-little-endian"),Tt=y();function xt(e,i){return r;function r(){var t=this[Tt];return t[i](e.byteOffset,Et)}}ge.exports=xt});var ye=u(function(au,me){"use strict";var Ot=require("@stdlib/assert-is-little-endian"),bt=require("@stdlib/boolean-ctor"),It=y();function St(e,i){return r;function r(){var t=this[It];return bt(t[i](e.byteOffset,Ot))}}me.exports=St});var de=u(function(su,he){"use strict";var qe=require("@stdlib/assert-is-little-endian"),At=require("@stdlib/complex-cmplx"),Ft=y(),Vt={complex128:"float64",complex64:"float32",complex32:"float16"};function Nt(e,i){return r;function r(){var t=this[Ft],s=t[i](e.byteOffset,qe),n=t[i](e.byteOffset+e.byteLength/2,qe);return At(s,n,Vt[e.type])}}he.exports=Nt});var Ee=u(function(uu,we){"use strict";var Pt=require("@stdlib/assert-is-little-endian"),Rt=y();function _t(e,i){return r;function r(){var t=this[Rt];return t[i](e.byteOffset,Pt)}}we.exports=_t});var xe=u(function(ou,Te){"use strict";var Lt=y();function Bt(e){return i;function i(){var r=this[Lt];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}Te.exports=Bt});var be=u(function(fu,Oe){"use strict";var Dt=require("@stdlib/array-typed"),Ut=y();function Ct(e){return i;function i(){var r=this[Ut];return Dt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}Oe.exports=Ct});var Se=u(function(vu,Ie){"use strict";var Mt=y();function kt(e){return i;function i(){var r,t,s,n;for(t=this[Mt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(aa("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=sa});var hr=u(function(_u,qr){"use strict";var ua=require("@stdlib/assert-is-string").isPrimitive,oa=require("@stdlib/string-format");function fa(e,i){return ua(e)?null:new TypeError(oa("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=fa});var wr=u(function(Lu,dr){"use strict";var va=require("@stdlib/assert-is-positive-integer").isPrimitive,la=require("@stdlib/string-format");function ca(e,i){return va(e)?null:new TypeError(la("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=ca});var Tr=u(function(Bu,Er){"use strict";var ga=require("@stdlib/assert-is-boolean").isPrimitive,pa=require("@stdlib/string-format");function ma(e,i){return ga(e)?null:new TypeError(pa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Er.exports=ma});var Or=u(function(Du,xr){"use strict";var ya=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=ya});var Sr=u(function(Uu,Ir){"use strict";var qa=require("@stdlib/array-base-assert-contains"),ha=require("@stdlib/array-base-join"),da=require("@stdlib/string-format"),wa=V(),br=Or();function Ea(e){return qa(br,e)||wa(e)?null:new TypeError(da('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",ha(br,", "),e))}Ir.exports=Ea});var Fr=u(function(Cu,Ar){"use strict";var Ta=require("@stdlib/array-base-assert-contains"),xa=require("@stdlib/array-base-join"),Oa=require("@stdlib/string-format");function ba(e){return i;function i(r,t){return Ta(e,r)?null:new TypeError(Oa('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,xa(e,", "),r))}}Ar.exports=ba});var Nr=u(function(Mu,Vr){"use strict";function Ia(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Ia});var Rr=u(function(ku,Pr){"use strict";var Sa=require("@stdlib/ndarray-base-bytes-per-element");function Aa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Sa(e.type),e.length&&(i*=e.length),i}Pr.exports=Aa});var Lr=u(function(Ju,_r){"use strict";var Fa=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Fa});var Dr=u(function(zu,Br){"use strict";var Va={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=Va});var ee=u(function(Gu,Mr){"use strict";var Na=require("@stdlib/assert-has-property"),Pa=require("@stdlib/array-base-join"),Ra=require("@stdlib/utils-constant-function"),_a=require("@stdlib/string-format"),La=pr(),Ba=V(),Da=yr(),Ua=hr(),Ca=wr(),Ur=Tr(),Ma=Sr(),ka=Fr(),Ja=Nr(),za=Rr(),Ga=Lr(),Wa=Dr(),Cr=["name","type"],Ha={name:Da,type:Ma,description:Ua,length:Ca,enumerable:Ur,writable:Ur,default:Ra(null),castingMode:ka(Ga)};function Ya(e,i){var r,t,s,n,a;for(r=Ja(),a=0;ai&&(i=r);return i}kr.exports=$a});var Gr=u(function(Hu,zr){"use strict";var Xa=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),te=require("@stdlib/string-format"),Ka=P(),Qa=j(),Za=ee(),ja=re();function es(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ie(a)&&Qr(n.fields,t)),a.byteOffset=s,ie(a))for(p=0;pI&&(I=F);for(s="%"+I+"s",n="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&l.byteOffset===i[m-1].byteOffset)){for(m1?a=" (byte %u)":a="",c){for(o=" => union: %s",v=[],R=m+1;R[%u]",E.name,E.type,T%E.alignment)),R+=1;o=q(o,v.join(", "))}else o="";v=q(a+o,T%l.alignment),l.length?w=q(n,q("%s[%u]%s",l.type,ps(T/l.alignment),v)):w=q(n,q("%s%s",l.type,v)),f.push(q(p,O,h,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){r=n.type.toString({format:"layout"}),i.push(ys(r,t,hs(n.byteOffset)));continue}i.push(ne("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=ne("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}st.exports=ds});var vt=u(function(eo,ft){"use strict";var ws=require("@stdlib/assert-is-plain-object"),Es=require("@stdlib/assert-has-own-property"),Ts=require("@stdlib/array-base-assert-contains").factory,xs=require("@stdlib/array-base-join"),ut=require("@stdlib/string-format"),Os=at(),bs=ae(),ot=["none","linear","layout"],Is=Ts(ot);function Ss(e,i,r){var t;if(!ws(r))throw new TypeError(ut("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Es(r,"format")&&(t.format=r.format,!Is(t.format)))throw new TypeError(ut('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",xs(ot,", "),r.format));return t.format==="linear"?Os(e.constructor,i):t.format==="layout"?bs(i):""}ft.exports=Ss});var ct=u(function(ro,lt){"use strict";var As=require("@stdlib/assert-is-collection"),Fs=require("@stdlib/assert-is-complex-like"),Vs=require("@stdlib/assert-is-function"),Ns=require("@stdlib/array-to-json"),Ps=V();function Rs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!Bs(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,oe,b),I!==void 0){for(O=Cs(void 0,a.length),w={},l=0;l0?c=arguments[0]:c={},Xs(this,a,c)}),d(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return Ks(this,a)}),v}yt.exports=Zs});var js=qt();module.exports=js; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9032b77..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\ttmp = o.type.toString({\n\t\t\t\t'format': 'layout'\n\t\t\t});\n\t\t\tout.push( replace( tmp, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAwBA,IAAIC,GAAmB,QAAS,iCAAkC,EAC9DC,GAAiB,IAarB,SAASC,GAAWC,EAAKC,EAAS,CACjC,OAAOC,EAQP,SAASA,GAAS,CACjB,IAAIC,EAAO,KAAML,EAAe,EAChC,OAAOK,EAAMF,CAAO,EAAGD,EAAI,WAAYH,EAA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AiB/DlC,EAAaqC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF7B,GAAe,KAAMU,EAAQmB,CAAK,CAC1C,CAAC,EAaDrD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCpajB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 5187713..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 37cb1cd..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9a02864 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as V}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.0-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.2-esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(p("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Tt,t)||vt(t)?null:new TypeError(p('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",l(Tt,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(p("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Z(t)?null:new TypeError(p("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Et,writable:Et,default:X(null),castingMode:(St=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(St,t)?null:new TypeError(p('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,l(St,", "),t))})};function Ut(t,e){var n,s,r,i,a;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},a=0;ae&&(e=n);return e}function Jt(t){var e,n,s,r,a,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[o-1].byteOffset||(i.isStructType?(n=i.type.toString({format:"layout"}),e.push(it(n,s,Mt(i.byteOffset)))):e.push(p("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=p("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var kt=["none","linear","layout"],At=et(kt);function Pt(t,e,n){var s;if(!st(n))throw new TypeError(p("null2V",n));if(s={format:"none"},rt(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(p("null4S","format",l(kt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,o,a,l,f,d,m,u,g,c,h,y,b,v,j,w,x,O;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,w=0;wh&&(h=y);for(s="%"+h+"s",r="// %s",a="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(o=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;o=p(o,l.join(", "))}else o="";l=p(i+o,x%v.alignment),c=v.length?p(r,p("%s[%u]%s",v.type,B(x/v.alignment),l)):p(r,p("%s%s",v.type,l)),f.push(p(a,u,g,c)),m+=1}for(x=0;x"}function Bt(y){var b,v,j,w,x,O,E,T;if(!s(y))throw new TypeError(p("null2O",y));if(E=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(p("null3L",e));y=e}if(t(this,lt,h),void 0!==y){for(d=f(void 0,O.length),c={},T=0;T0&&((i=t[l-1]).padding=s,Ot(o)&&Nt(i.fields,s)),o.byteOffset=r,Ot(o))for(f=0;f0?arguments[0]:{})})),t(S.prototype,"toJSON",(function(){if(!(this instanceof S))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,o;for(n={},o=0;o} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\ttmp = o.type.toString({\n\t\t\t\t'format': 'layout'\n\t\t\t});\n\t\t\tout.push( replace( tmp, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","replacer","match","p1","parseInt","layoutFormat","N","toString","replace","substring","FORMATS","isFormat","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;0zLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAKC,YAAaP,EAAKQ,OAAQT,EAAQH,EAAIa,aAC7DV,GAAUH,EAAIQ,WAEf,OAAOH,CACP,CACF,CDdUS,CAAgBd,GET1B,SAAwBA,GACvB,OAQA,WACC,IAAII,EAAOG,KAAM5B,IACjB,OAAOoC,EAAYX,EAAKQ,OAAQR,EAAKI,WAAWR,EAAIQ,WAAYR,EAAIC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AAQxF,IAEZvB,EAAM8E,GAAQgE,GACTA,EAAEpB,WACDoB,EAAEnB,SACNsF,EAAsBD,EAAGlE,EAAE3E,KAAMpE,EAAKC,GAEtCkN,EAAqBF,EAAGlE,EAAE3E,KAAMpE,GAEtB+I,EAAEnB,SACbwF,EAAmCH,EAAGlE,EAAE3E,KAAMpE,EAAKC,GAEnD4M,EAAkCI,EAAGlE,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CN+Wa8L,CAA0BlD,EAAOmD,UAAW5B,GAiBxDa,EAAapC,EAAOmD,UAAW,YAAY,WAE1C,KAAQ7L,gBAAgB0I,GACvB,MAAM,IAAItH,MAAO,wDAOlB,OAAO0K,GAAe9L,KAAMiK,EALvBO,UAAU9K,OAAS,EAChB8K,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAapC,EAAOmD,UAAW,UAAU,WACxC,KAAQ7L,gBAAgB0I,GACvB,MAAM,IAAItH,MAAO,wDAElB,OOzbF,SAAiBiH,EAAQ9C,GACxB,IAAIzF,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B+B,EAAIuG,GADJf,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAIiK,GAAiBjK,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAOkK,GAAYlK,EAAEmK,WAD/CnK,EAAIA,EAAEmK,UAIPnM,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqaSoM,CAAalM,KAAMiK,EAC5B,IAEQvB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index c6191c3..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - tmp = o.type.toString({ - 'format': 'layout' - }); - out.push( replace( tmp, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f991b05..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,175 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index b8ce685..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4b85892..0000000 --- a/lib/main.js +++ /dev/null @@ -1,490 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 7420006..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index e0c3b81..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,89 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c28090e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 12d0d0bbfdf7ff1df07d633128a9771fbe88b020 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 08:29:35 +0000 Subject: [PATCH 21/84] Transform error messages --- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 24 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index 98552eb..c6191c3 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index af9cccf..f991b05 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 3a35369..c9f87b6 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStruct = require( './is_struct.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index b8792dc..b330dd8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var filled = require( '@stdlib/array-base-filled' ); var indexOf = require( '@stdlib/array-base-index-of' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 3bea9ed..1d27b6c 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStruct = require( './is_struct.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index fb29c04..bbaec31 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 41bd4a1..7420006 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStruct = require( './is_struct.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 974100c..e0c3b81 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 4416b1189dfcaa0e7d4dfb739d6d275070cabf19 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 08:29:55 +0000 Subject: [PATCH 22/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9a02864..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as V}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.0-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.2-esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(p("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Tt,t)||vt(t)?null:new TypeError(p('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",l(Tt,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(p("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Z(t)?null:new TypeError(p("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Et,writable:Et,default:X(null),castingMode:(St=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(St,t)?null:new TypeError(p('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,l(St,", "),t))})};function Ut(t,e){var n,s,r,i,a;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},a=0;ae&&(e=n);return e}function Jt(t){var e,n,s,r,a,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[o-1].byteOffset||(i.isStructType?(n=i.type.toString({format:"layout"}),e.push(it(n,s,Mt(i.byteOffset)))):e.push(p("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=p("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var kt=["none","linear","layout"],At=et(kt);function Pt(t,e,n){var s;if(!st(n))throw new TypeError(p("null2V",n));if(s={format:"none"},rt(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(p("null4S","format",l(kt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,o,a,l,f,d,m,u,g,c,h,y,b,v,j,w,x,O;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,w=0;wh&&(h=y);for(s="%"+h+"s",r="// %s",a="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(o=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;o=p(o,l.join(", "))}else o="";l=p(i+o,x%v.alignment),c=v.length?p(r,p("%s[%u]%s",v.type,B(x/v.alignment),l)):p(r,p("%s%s",v.type,l)),f.push(p(a,u,g,c)),m+=1}for(x=0;x"}function Bt(y){var b,v,j,w,x,O,E,T;if(!s(y))throw new TypeError(p("null2O",y));if(E=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(p("null3L",e));y=e}if(t(this,lt,h),void 0!==y){for(d=f(void 0,O.length),c={},T=0;T0&&((i=t[l-1]).padding=s,Ot(o)&&Nt(i.fields,s)),o.byteOffset=r,Ot(o))for(f=0;f0?arguments[0]:{})})),t(S.prototype,"toJSON",(function(){if(!(this instanceof S))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,o;for(n={},o=0;o} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\ttmp = o.type.toString({\n\t\t\t\t'format': 'layout'\n\t\t\t});\n\t\t\tout.push( replace( tmp, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","replacer","match","p1","parseInt","layoutFormat","N","toString","replace","substring","FORMATS","isFormat","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;0zLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UA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AM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B+B,EAAIuG,GADJf,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAIiK,GAAiBjK,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAOkK,GAAYlK,EAAEmK,WAD/CnK,EAAIA,EAAEmK,UAIPnM,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqaSoM,CAAalM,KAAMiK,EAC5B,IAEQvB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c28090e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 34abf42664f66671f8fc5d7f13ea5f810410ecf6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 08:30:23 +0000 Subject: [PATCH 23/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 74 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 130 - lib/format_linear.js | 175 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 490 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 98 files changed, 4863 insertions(+), 8408 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11b01cd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(ru,fe){"use strict";var ht="__@@##$$@@__struct_buffer__@@$$##@@__";fe.exports=ht});var le=u(function(tu,ve){"use strict";var dt="Struct";ve.exports=dt});var W=u(function(iu,ce){"use strict";var wt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ce.exports=wt});var pe=u(function(nu,ge){"use strict";var Et=require("@stdlib/assert-is-little-endian"),Tt=y();function xt(e,i){return r;function r(){var t=this[Tt];return t[i](e.byteOffset,Et)}}ge.exports=xt});var ye=u(function(au,me){"use strict";var Ot=require("@stdlib/assert-is-little-endian"),bt=require("@stdlib/boolean-ctor"),It=y();function St(e,i){return r;function r(){var t=this[It];return bt(t[i](e.byteOffset,Ot))}}me.exports=St});var de=u(function(su,he){"use strict";var qe=require("@stdlib/assert-is-little-endian"),At=require("@stdlib/complex-cmplx"),Ft=y(),Vt={complex128:"float64",complex64:"float32",complex32:"float16"};function Nt(e,i){return r;function r(){var t=this[Ft],s=t[i](e.byteOffset,qe),n=t[i](e.byteOffset+e.byteLength/2,qe);return At(s,n,Vt[e.type])}}he.exports=Nt});var Ee=u(function(uu,we){"use strict";var Pt=require("@stdlib/assert-is-little-endian"),Rt=y();function _t(e,i){return r;function r(){var t=this[Rt];return t[i](e.byteOffset,Pt)}}we.exports=_t});var xe=u(function(ou,Te){"use strict";var Lt=y();function Bt(e){return i;function i(){var r=this[Lt];return new e.type.constructor(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}Te.exports=Bt});var be=u(function(fu,Oe){"use strict";var Dt=require("@stdlib/array-typed"),Ut=y();function Ct(e){return i;function i(){var r=this[Ut];return Dt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}Oe.exports=Ct});var Se=u(function(vu,Ie){"use strict";var Mt=y();function kt(e){return i;function i(){var r,t,s,n;for(t=this[Mt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(aa("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=sa});var hr=u(function(_u,qr){"use strict";var ua=require("@stdlib/assert-is-string").isPrimitive,oa=require("@stdlib/string-format");function fa(e,i){return ua(e)?null:new TypeError(oa("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=fa});var wr=u(function(Lu,dr){"use strict";var va=require("@stdlib/assert-is-positive-integer").isPrimitive,la=require("@stdlib/string-format");function ca(e,i){return va(e)?null:new TypeError(la("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=ca});var Tr=u(function(Bu,Er){"use strict";var ga=require("@stdlib/assert-is-boolean").isPrimitive,pa=require("@stdlib/string-format");function ma(e,i){return ga(e)?null:new TypeError(pa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Er.exports=ma});var Or=u(function(Du,xr){"use strict";var ya=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=ya});var Sr=u(function(Uu,Ir){"use strict";var qa=require("@stdlib/array-base-assert-contains"),ha=require("@stdlib/array-base-join"),da=require("@stdlib/string-format"),wa=V(),br=Or();function Ea(e){return qa(br,e)||wa(e)?null:new TypeError(da('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",ha(br,", "),e))}Ir.exports=Ea});var Fr=u(function(Cu,Ar){"use strict";var Ta=require("@stdlib/array-base-assert-contains"),xa=require("@stdlib/array-base-join"),Oa=require("@stdlib/string-format");function ba(e){return i;function i(r,t){return Ta(e,r)?null:new TypeError(Oa('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,xa(e,", "),r))}}Ar.exports=ba});var Nr=u(function(Mu,Vr){"use strict";function Ia(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Ia});var Rr=u(function(ku,Pr){"use strict";var Sa=require("@stdlib/ndarray-base-bytes-per-element");function Aa(e){var i;return e.isStructType?i=e.type.constructor.byteLength:i=Sa(e.type),e.length&&(i*=e.length),i}Pr.exports=Aa});var Lr=u(function(Ju,_r){"use strict";var Fa=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Fa});var Dr=u(function(zu,Br){"use strict";var Va={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=Va});var ee=u(function(Gu,Mr){"use strict";var Na=require("@stdlib/assert-has-property"),Pa=require("@stdlib/array-base-join"),Ra=require("@stdlib/utils-constant-function"),_a=require("@stdlib/string-format"),La=pr(),Ba=V(),Da=yr(),Ua=hr(),Ca=wr(),Ur=Tr(),Ma=Sr(),ka=Fr(),Ja=Nr(),za=Rr(),Ga=Lr(),Wa=Dr(),Cr=["name","type"],Ha={name:Da,type:Ma,description:Ua,length:Ca,enumerable:Ur,writable:Ur,default:Ra(null),castingMode:ka(Ga)};function Ya(e,i){var r,t,s,n,a;for(r=Ja(),a=0;ai&&(i=r);return i}kr.exports=$a});var Gr=u(function(Hu,zr){"use strict";var Xa=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),te=require("@stdlib/string-format"),Ka=P(),Qa=j(),Za=ee(),ja=re();function es(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ie(a)&&Qr(n.fields,t)),a.byteOffset=s,ie(a))for(p=0;pI&&(I=F);for(s="%"+I+"s",n="// %s",p="%s: %s %s",g=0,f=[],m=0;m0&&l.byteOffset===i[m-1].byteOffset)){for(m1?a=" (byte %u)":a="",c){for(o=" => union: %s",v=[],R=m+1;R[%u]",E.name,E.type,T%E.alignment)),R+=1;o=q(o,v.join(", "))}else o="";v=q(a+o,T%l.alignment),l.length?w=q(n,q("%s[%u]%s",l.type,ps(T/l.alignment),v)):w=q(n,q("%s%s",l.type,v)),f.push(q(p,O,h,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){r=n.type.toString({format:"layout"}),i.push(ys(r,t,hs(n.byteOffset)));continue}i.push(ne("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=ne("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}st.exports=ds});var vt=u(function(eo,ft){"use strict";var ws=require("@stdlib/assert-is-plain-object"),Es=require("@stdlib/assert-has-own-property"),Ts=require("@stdlib/array-base-assert-contains").factory,xs=require("@stdlib/array-base-join"),ut=require("@stdlib/string-format"),Os=at(),bs=ae(),ot=["none","linear","layout"],Is=Ts(ot);function Ss(e,i,r){var t;if(!ws(r))throw new TypeError(ut("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Es(r,"format")&&(t.format=r.format,!Is(t.format)))throw new TypeError(ut('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",xs(ot,", "),r.format));return t.format==="linear"?Os(e.constructor,i):t.format==="layout"?bs(i):""}ft.exports=Ss});var ct=u(function(ro,lt){"use strict";var As=require("@stdlib/assert-is-collection"),Fs=require("@stdlib/assert-is-complex-like"),Vs=require("@stdlib/assert-is-function"),Ns=require("@stdlib/array-to-json"),Ps=V();function Rs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!Bs(f))throw new TypeError(x("invalid argument. First argument must be an object. Value: `%s`.",f));I=f}if(d(this,oe,b),I!==void 0){for(O=Cs(void 0,a.length),w={},l=0;l0?c=arguments[0]:c={},Xs(this,a,c)}),d(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return Ks(this,a)}),v}yt.exports=Zs});var js=qt();module.exports=js; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 15093c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStruct = require( './is_struct.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStruct = require( './is_struct.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStruct = require( './is_struct.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\ttmp = o.type.toString({\n\t\t\t\t'format': 'layout'\n\t\t\t});\n\t\t\tout.push( replace( tmp, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStruct = require( './is_struct.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar join = require( '@stdlib/array-base-join' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStruct = require( './is_struct.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAA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E,MAC9B,CAAC,EAcDd,EAAaqC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIO,EACJ,GAAK,CAACnC,GAAU4B,CAAI,EACnB,MAAM,IAAI,UAAWhC,EAAQ,6EAA8EgC,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAK/B,EAAe,EACnB,IAAIF,EAAUwC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYjB,GAA0BqB,EAAO,UAAWH,CAAO,EAiB/DlC,EAAaqC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF7B,GAAe,KAAMU,EAAQmB,CAAK,CAC1C,CAAC,EAaDrD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCpajB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStruct", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStruct", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStruct", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStruct", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStruct", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStruct", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "join", "filled", "indexOf", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStruct", "normalize", "fieldNames", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 5187713..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 37cb1cd..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': new Struct1(), - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dc8610a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as _}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(p("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Tt,t)||vt(t)?null:new TypeError(p('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",l(Tt,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(p("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Z(t)?null:new TypeError(p("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Et,writable:Et,default:X(null),castingMode:(St=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(St,t)?null:new TypeError(p('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,l(St,", "),t))})};function Ut(t,e){var n,s,r,i,a;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},a=0;ae&&(e=n);return e}function Jt(t){var e,n,s,r,a,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[o-1].byteOffset||(i.isStructType?(n=i.type.toString({format:"layout"}),e.push(it(n,s,Mt(i.byteOffset)))):e.push(p("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=p("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var At=["none","linear","layout"],Pt=et(At);function kt(t,e,n){var s;if(!st(n))throw new TypeError(p("null2V",n));if(s={format:"none"},rt(n,"format")&&(s.format=n.format,!Pt(s.format)))throw new TypeError(p("null4S","format",l(At,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,o,a,l,f,d,m,u,g,c,h,y,b,v,j,w,x,O;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,w=0;wh&&(h=y);for(s="%"+h+"s",r="// %s",a="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(o=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;o=p(o,l.join(", "))}else o="";l=p(i+o,x%v.alignment),c=v.length?p(r,p("%s[%u]%s",v.type,k(x/v.alignment),l)):p(r,p("%s%s",v.type,l)),f.push(p(a,u,g,c)),m+=1}for(x=0;x"}function Bt(y){var b,v,j,w,x,O,E,T;if(!s(y))throw new TypeError(p("null2O",y));if(E=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(p("null3L",e));y=e}if(t(this,lt,h),void 0!==y){for(d=f(void 0,O.length),c={},T=0;T0&&((i=t[l-1]).padding=s,Ot(o)&&Nt(i.fields,s)),o.byteOffset=r,Ot(o))for(f=0;f0?arguments[0]:{})})),t(S.prototype,"toJSON",(function(){if(!(this instanceof S))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,o;for(n={},o=0;o} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\ttmp = o.type.toString({\n\t\t\t\t'format': 'layout'\n\t\t\t});\n\t\t\tout.push( replace( tmp, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","replacer","match","p1","parseInt","layoutFormat","N","toString","replace","substring","FORMATS","isFormat","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;2zLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,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F,EAAmCH,EAAGlE,EAAE3E,KAAMpE,EAAKC,GAEnD4M,EAAkCI,EAAGlE,EAAE3E,KAAMpE,GAE9CuB,EAAKwH,EAAE3E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CN+Wa8L,CAA0BlD,EAAOmD,UAAW5B,GAiBxDa,EAAapC,EAAOmD,UAAW,YAAY,WAE1C,KAAQ7L,gBAAgB0I,GACvB,MAAM,IAAItH,MAAO,wDAOlB,OAAO0K,GAAe9L,KAAMiK,EALvBO,UAAU9K,OAAS,EAChB8K,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAapC,EAAOmD,UAAW,UAAU,WACxC,KAAQ7L,gBAAgB0I,GACvB,MAAM,IAAItH,MAAO,wDAElB,OOzbF,SAAiBiH,EAAQ9C,GACxB,IAAIzF,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B+B,EAAIuG,GADJf,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAIiK,GAAiBjK,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAOkK,GAAYlK,EAAEmK,WAD/CnK,EAAIA,EAAEmK,UAIPnM,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqaSoM,CAAalM,KAAMiK,EAC5B,IAEQvB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index b86fd9d..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.constructor.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index c6191c3..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - tmp = o.type.toString({ - 'format': 'layout' - }); - out.push( replace( tmp, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f991b05..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,175 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - tmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 7f8ae8c..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index dad36ce..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct.js b/lib/is_struct.js deleted file mode 100644 index b8ce685..0000000 --- a/lib/is_struct.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStruct( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStruct; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index c9f87b6..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStruct = require( './is_struct.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStruct( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index b330dd8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,490 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var join = require( '@stdlib/array-base-join' ); -var filled = require( '@stdlib/array-base-filled' ); -var indexOf = require( '@stdlib/array-base-index-of' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStruct = require( './is_struct.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx; - if ( FIELD_NAMES.length === 0 ) { - throw new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( FIELD_NAMES, name, 0 ); - if ( idx < 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following: "%s". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) ); - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instace - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStruct( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 1d27b6c..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStruct = require( './is_struct.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStruct( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.constructor.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index bbaec31..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index 7420006..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStruct = require( './is_struct.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStruct( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 5207dc3..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStruct = require( './is_struct.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStruct( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index e0c3b81..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,89 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8ee243a --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From e7db4b752468c572aad3119e0c7ef9aa899bfbfe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 10:02:44 +0000 Subject: [PATCH 24/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 259f09d..beaea8e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStructType = require( './is_struct_type.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 10137c8..bb41688 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -115,7 +115,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -190,7 +190,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -208,7 +208,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 9f50475..051a4db 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStructType = require( './is_struct_type.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 974100c..e0c3b81 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 9d6edaf3e191b2dc8011c72be79f7cb7602e3532 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 10:03:11 +0000 Subject: [PATCH 25/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dc8610a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as _}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(p("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Tt,t)||vt(t)?null:new TypeError(p('invalid argument. `%s` field must be either a `struct` or one of the following: "%s". Value: `%s`.',"type",l(Tt,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(p("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Z(t)?null:new TypeError(p("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Et,writable:Et,default:X(null),castingMode:(St=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(St,t)?null:new TypeError(p('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,l(St,", "),t))})};function Ut(t,e){var n,s,r,i,a;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},a=0;ae&&(e=n);return e}function Jt(t){var e,n,s,r,a,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[o-1].byteOffset||(i.isStructType?(n=i.type.toString({format:"layout"}),e.push(it(n,s,Mt(i.byteOffset)))):e.push(p("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=p("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var At=["none","linear","layout"],Pt=et(At);function kt(t,e,n){var s;if(!st(n))throw new TypeError(p("null2V",n));if(s={format:"none"},rt(n,"format")&&(s.format=n.format,!Pt(s.format)))throw new TypeError(p("null4S","format",l(At,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,o,a,l,f,d,m,u,g,c,h,y,b,v,j,w,x,O;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,w=0;wh&&(h=y);for(s="%"+h+"s",r="// %s",a="%s: %s %s",m=0,f=[],w=0;w0&&v.byteOffset===e[w-1].byteOffset)){for(d=w1?" (byte %u)":"",d){for(o=" => union: %s",l=[],O=w+1;O[%u]",j.name,j.type,x%j.alignment)),O+=1;o=p(o,l.join(", "))}else o="";l=p(i+o,x%v.alignment),c=v.length?p(r,p("%s[%u]%s",v.type,k(x/v.alignment),l)):p(r,p("%s%s",v.type,l)),f.push(p(a,u,g,c)),m+=1}for(x=0;x"}function Bt(y){var b,v,j,w,x,O,E,T;if(!s(y))throw new TypeError(p("null2O",y));if(E=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(p("null3L",e));y=e}if(t(this,lt,h),void 0!==y){for(d=f(void 0,O.length),c={},T=0;T0&&((i=t[l-1]).padding=s,Ot(o)&&Nt(i.fields,s)),o.byteOffset=r,Ot(o))for(f=0;f0?arguments[0]:{})})),t(S.prototype,"toJSON",(function(){if(!(this instanceof S))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,o;for(n={},o=0;o} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type.constructor( view.buffer, offset, obj.byteLength ) ); // eslint-disable-line max-len\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type.constructor( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStruct( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStruct( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStruct from './is_struct.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStruct( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.constructor.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStruct from './is_struct.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStruct( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a `struct` or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.constructor.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\ttmp = o.type.toString({\n\t\t\t\t'format': 'layout'\n\t\t\t});\n\t\t\tout.push( replace( tmp, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, f.type, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport join from '@stdlib/array-base-join';\nimport filled from '@stdlib/array-base-filled';\nimport indexOf from '@stdlib/array-base-index-of';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStruct from './is_struct.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx;\n\t\tif ( FIELD_NAMES.length === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. struct does not have any fields.' );\n\t\t}\n\t\tidx = indexOf( FIELD_NAMES, name, 0 );\n\t\tif ( idx < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following: \"%s\". Value: `%s`.', join( FIELD_NAMES, ', ' ), name ) );\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instace\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStruct( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStruct from './is_struct.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStruct( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","constructor","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStruct","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","setPadding","replacer","match","p1","parseInt","layoutFormat","N","toString","replace","substring","FORMATS","isFormat","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","idx","indexOf","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;2zLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAA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9C,GACxB,IAAIzF,EACAwH,EACAxF,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B+B,EAAIuG,GADJf,EAAI/B,EAAQxF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAIiK,GAAiBjK,IACVoB,GAAUpB,IAEVQ,EAAeR,IAAOkK,GAAYlK,EAAEmK,WAD/CnK,EAAIA,EAAEmK,UAIPnM,EAAKwH,EAAE3E,MAASb,EAEjB,OAAOhC,CACR,CPqaSoM,CAAalM,KAAMiK,EAC5B,IAEQvB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8ee243a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5661282d1df122bd9879fb6280d6d045bb807c49 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 20 Jun 2025 10:03:37 +0000 Subject: [PATCH 26/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 87 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_struct_type.js | 51 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 501 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8541 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_struct_type.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 89697db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(cu,le){"use strict";var Ot="__@@##$$@@__struct_buffer__@@$$##@@__";le.exports=Ot});var ge=u(function(gu,ce){"use strict";var bt="Struct";ce.exports=bt});var $=u(function(pu,pe){"use strict";var It={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};pe.exports=It});var me=u(function(yu,ye){"use strict";var St=require("@stdlib/assert-is-little-endian"),At=y();function Ft(e,i){return r;function r(){var t=this[At];return t[i](e.byteOffset,St)}}ye.exports=Ft});var he=u(function(mu,qe){"use strict";var Nt=require("@stdlib/assert-is-little-endian"),Vt=require("@stdlib/boolean-ctor"),Pt=y();function Rt(e,i){return r;function r(){var t=this[Pt];return Vt(t[i](e.byteOffset,Nt))}}qe.exports=Rt});var we=u(function(qu,Ee){"use strict";var de=require("@stdlib/assert-is-little-endian"),Lt=require("@stdlib/complex-cmplx"),_t=y(),Bt={complex128:"float64",complex64:"float32",complex32:"float16"};function Dt(e,i){return r;function r(){var t=this[_t],s=t[i](e.byteOffset,de),n=t[i](e.byteOffset+e.byteLength/2,de);return Lt(s,n,Bt[e.type])}}Ee.exports=Dt});var xe=u(function(hu,Te){"use strict";var Ut=require("@stdlib/assert-is-little-endian"),Ct=y();function Mt(e,i){return r;function r(){var t=this[Ct];return t[i](e.byteOffset,Ut)}}Te.exports=Mt});var be=u(function(du,Oe){"use strict";var kt=y();function Jt(e){return i;function i(){var r=this[kt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}Oe.exports=Jt});var Se=u(function(Eu,Ie){"use strict";var zt=require("@stdlib/array-typed"),Gt=y();function Wt(e){return i;function i(){var r=this[Gt];return zt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}Ie.exports=Wt});var Fe=u(function(wu,Ae){"use strict";var Ht=y();function Yt(e){return i;function i(){var r,t,s,n;for(t=this[Ht],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ca("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}dr.exports=ga});var Tr=u(function(Hu,wr){"use strict";var pa=require("@stdlib/assert-is-string").isPrimitive,ya=require("@stdlib/string-format");function ma(e,i){return pa(e)?null:new TypeError(ya("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}wr.exports=ma});var Or=u(function(Yu,xr){"use strict";var qa=require("@stdlib/assert-is-positive-integer").isPrimitive,ha=require("@stdlib/string-format");function da(e,i){return qa(e)?null:new TypeError(ha("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}xr.exports=da});var Ir=u(function($u,br){"use strict";var Ea=require("@stdlib/assert-is-boolean").isPrimitive,wa=require("@stdlib/string-format");function Ta(e,i){return Ea(e)?null:new TypeError(wa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}br.exports=Ta});var Ar=u(function(Xu,Sr){"use strict";var xa=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Sr.exports=xa});var Vr=u(function(Ku,Nr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format"),Sa=ie(),Fr=Ar();function Aa(e){return Oa(Fr,e)||Sa(e)?null:new TypeError(Ia('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",ba(Fr,", "),e))}Nr.exports=Aa});var Rr=u(function(Qu,Pr){"use strict";var Fa=require("@stdlib/array-base-assert-contains"),Na=require("@stdlib/array-base-join"),Va=require("@stdlib/string-format");function Pa(e){return i;function i(r,t){return Fa(e,r)?null:new TypeError(Va('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,Na(e,", "),r))}}Pr.exports=Pa});var _r=u(function(Zu,Lr){"use strict";function Ra(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Lr.exports=Ra});var Dr=u(function(ju,Br){"use strict";var La=require("@stdlib/ndarray-base-bytes-per-element");function _a(e){var i;return e.isStructType?i=e.type.byteLength:i=La(e.type),e.length&&(i*=e.length),i}Br.exports=_a});var Cr=u(function(eo,Ur){"use strict";var Ba=["none","safe","mostly-safe","same-kind","unsafe"];Ur.exports=Ba});var kr=u(function(ro,Mr){"use strict";var Da={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Mr.exports=Da});var ne=u(function(to,Gr){"use strict";var Ua=require("@stdlib/assert-has-property"),Ca=require("@stdlib/array-base-join"),Ma=require("@stdlib/utils-constant-function"),ka=require("@stdlib/string-format"),Ja=mr(),za=ie(),Ga=Er(),Wa=Tr(),Ha=Or(),Jr=Ir(),Ya=Vr(),$a=Rr(),Xa=_r(),Ka=Dr(),Qa=Cr(),Za=kr(),zr=["name","type"],ja={name:Ga,type:Ya,description:Wa,length:Ha,enumerable:Jr,writable:Jr,default:Ma(null),castingMode:$a(Qa)};function es(e,i){var r,t,s,n,a;for(r=Xa(),a=0;ai&&(i=r);return i}Wr.exports=rs});var $r=u(function(no,Yr){"use strict";var ts=require("@stdlib/assert-is-object"),Hr=require("@stdlib/assert-has-property"),se=require("@stdlib/string-format"),is=P(),ns=te(),as=ne(),ss=ae();function us(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ue(a)&&it(n.fields,t)),a.byteOffset=s,ue(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",c=0,f=[],q=0;q0&&l.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",g){for(o=" => union: %s",v=[],R=q+1;R":F=E.type,v.push(m("%s<%s>[%u]",E.name,F,T%E.alignment)),R+=1;o=m(o,v.join(", "))}else o="";v=m(a+o,T%l.alignment),l.length?w=m(n,m("%s[%u]%s",l.type,bs(T/l.alignment),v)):w=m(n,m("%s%s",l.type,v)),f.push(m(p,x,h,w)),c+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ss(n.type.layout,t,Fs(n.byteOffset)));continue}i.push(oe("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=oe("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ct.exports=Ns});var mt=u(function(go,yt){"use strict";var Vs=require("@stdlib/assert-is-plain-object"),Ps=require("@stdlib/assert-has-own-property"),Rs=require("@stdlib/array-base-assert-contains").factory,Ls=require("@stdlib/array-base-join"),gt=require("@stdlib/string-format"),_s=lt(),Bs=fe(),pt=["none","linear","layout"],Ds=Rs(pt);function Us(e,i,r){var t;if(!Vs(r))throw new TypeError(gt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ps(r,"format")&&(t.format=r.format,!Ds(t.format)))throw new TypeError(gt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Ls(pt,", "),r.format));return t.format==="linear"?_s(e.constructor,i):t.format==="layout"?Bs(i):""}yt.exports=Us});var ht=u(function(po,qt){"use strict";var Cs=require("@stdlib/assert-is-collection"),Ms=require("@stdlib/assert-is-complex-like"),ks=require("@stdlib/assert-is-function"),Js=require("@stdlib/array-to-json"),zs=L();function Gs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!Ys(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(d(this,ve,O),b!==void 0){for(x=Ks(void 0,a.length),w={},l=0;l0?g=arguments[0]:g={},su(this,a,g)}),d(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return uu(this,a)}),v}Tt.exports=fu});var vu=xt();module.exports=vu; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 86b3ba7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_struct_type.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStructType = require( './is_struct_type.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStructType = require( './is_struct_type.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,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OAAAO,EAAMP,EAAKhC,EAAe,EACnB,IAAIF,EAAUyC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYlB,GAA0BsB,EAAO,UAAWH,CAAO,EAiB/DjC,EAAaoC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF7B,GAAe,KAAMU,EAAQmB,CAAK,CAC1C,CAAC,EAaDpD,EAAaoC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKArC,GAAO,QAAU2B,KC/ajB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_struct_type", "__commonJSMin", "exports", "module", "isPositiveInteger", "isFunction", "isStructType", "value", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStructType", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStructType", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3c36db7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as G}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(St,t)||Et(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",q(St,", "),t))},description:function(t,e){return Q(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return G(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:C(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Lt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,q(Lt,", "),t))})};function It(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function Nt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(rt(i.type.layout,s,kt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Pt=["none","linear","layout"],Bt=Y(Pt);function Rt(t,e,n){var s;if(!et(n))throw new TypeError(m("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!Bt(s.format)))throw new TypeError(m("null4S","format",q(Pt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,st(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function Dt(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,lt,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,Ot(a)&&_t(i.fields,s)),a.byteOffset=r,Ot(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isFunction from '@stdlib/assert-is-function';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStructType from './is_struct_type.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStructType from './is_struct_type.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isFunction","isPositiveInteger","alignment","byteLengthOf","byteOffsetOf","bufferOf","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","toJSON","struct2json"],"mappings":";;yyLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjD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ACVoB,GAAkBpB,IAElBQ,GAAeR,IAAO2D,GAAY3D,EAAE2K,WAD/C3K,EAAIA,EAAE2K,UAIP1M,EAAK4H,EAAEhF,MAASb,EAEjB,OAAO/B,CACR,CPgbS2M,CAAazM,KAAM2K,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_struct_type.js b/lib/is_struct_type.js deleted file mode 100644 index f090e66..0000000 --- a/lib/is_struct_type.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructType( value ) { - return ( - isFunction( value ) && - isPositiveInteger( value.alignment ) && - isPositiveInteger( value.byteLength ) && - isFunction( value.byteLengthOf ) && - isFunction( value.byteOffsetOf ) && - isFunction( value.bufferOf ) && - isFunction( value.viewOf ) - ); -} - - -// EXPORTS // - -module.exports = isStructType; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index beaea8e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStructType = require( './is_struct_type.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructType( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bb41688..0000000 --- a/lib/main.js +++ /dev/null @@ -1,501 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 051a4db..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStructType = require( './is_struct_type.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructType( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index e0c3b81..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,89 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..180c2fa --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 4017c184f8a7b694192096f7224e3c6ce61a3c01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Jun 2025 12:43:48 +0000 Subject: [PATCH 27/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 259f09d..beaea8e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStructType = require( './is_struct_type.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 10137c8..bb41688 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -115,7 +115,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -190,7 +190,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -208,7 +208,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 9f50475..051a4db 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStructType = require( './is_struct_type.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 974100c..e0c3b81 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 55f5a83fa4e7c5f459ffe58407882897b2c00c8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Jun 2025 12:44:10 +0000 Subject: [PATCH 28/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3c36db7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as G}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(St,t)||Et(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",q(St,", "),t))},description:function(t,e){return Q(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return G(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:C(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Lt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,q(Lt,", "),t))})};function It(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function Nt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(rt(i.type.layout,s,kt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Pt=["none","linear","layout"],Bt=Y(Pt);function Rt(t,e,n){var s;if(!et(n))throw new TypeError(m("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!Bt(s.format)))throw new TypeError(m("null4S","format",q(Pt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,st(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function Dt(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,lt,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,Ot(a)&&_t(i.fields,s)),a.byteOffset=r,Ot(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isFunction from '@stdlib/assert-is-function';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStructType from './is_struct_type.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStructType from './is_struct_type.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isFunction","isPositiveInteger","alignment","byteLengthOf","byteOffsetOf","bufferOf","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","toJSON","struct2json"],"mappings":";;yyLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAA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ACvB,MAAM,IAAIhI,MAAO,wDAOlB,OAAOmL,GAAetM,KAAM2K,EALvBO,UAAUxL,OAAS,EAChBwL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAarC,EAAOkD,UAAW,UAAU,WACxC,KAAQrM,gBAAgBmJ,GACvB,MAAM,IAAIhI,MAAO,wDAElB,OOpcF,SAAiB2H,EAAQvD,GACxB,IAAIzF,EACA4H,EACA7F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIiH,GADJpB,EAAInC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAI0K,GAAiB1K,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAO2D,GAAY3D,EAAE2K,WAD/C3K,EAAIA,EAAE2K,UAIP1M,EAAK4H,EAAEhF,MAASb,EAEjB,OAAO/B,CACR,CPgbS2M,CAAazM,KAAM2K,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 180c2fa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0355c25e5af91d644dee72e5d9f5da9669d1bbfe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Jun 2025 12:44:34 +0000 Subject: [PATCH 29/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 88 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_struct_type.js | 51 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 501 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8542 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_struct_type.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 89697db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(cu,le){"use strict";var Ot="__@@##$$@@__struct_buffer__@@$$##@@__";le.exports=Ot});var ge=u(function(gu,ce){"use strict";var bt="Struct";ce.exports=bt});var $=u(function(pu,pe){"use strict";var It={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};pe.exports=It});var me=u(function(yu,ye){"use strict";var St=require("@stdlib/assert-is-little-endian"),At=y();function Ft(e,i){return r;function r(){var t=this[At];return t[i](e.byteOffset,St)}}ye.exports=Ft});var he=u(function(mu,qe){"use strict";var Nt=require("@stdlib/assert-is-little-endian"),Vt=require("@stdlib/boolean-ctor"),Pt=y();function Rt(e,i){return r;function r(){var t=this[Pt];return Vt(t[i](e.byteOffset,Nt))}}qe.exports=Rt});var we=u(function(qu,Ee){"use strict";var de=require("@stdlib/assert-is-little-endian"),Lt=require("@stdlib/complex-cmplx"),_t=y(),Bt={complex128:"float64",complex64:"float32",complex32:"float16"};function Dt(e,i){return r;function r(){var t=this[_t],s=t[i](e.byteOffset,de),n=t[i](e.byteOffset+e.byteLength/2,de);return Lt(s,n,Bt[e.type])}}Ee.exports=Dt});var xe=u(function(hu,Te){"use strict";var Ut=require("@stdlib/assert-is-little-endian"),Ct=y();function Mt(e,i){return r;function r(){var t=this[Ct];return t[i](e.byteOffset,Ut)}}Te.exports=Mt});var be=u(function(du,Oe){"use strict";var kt=y();function Jt(e){return i;function i(){var r=this[kt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}Oe.exports=Jt});var Se=u(function(Eu,Ie){"use strict";var zt=require("@stdlib/array-typed"),Gt=y();function Wt(e){return i;function i(){var r=this[Gt];return zt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}Ie.exports=Wt});var Fe=u(function(wu,Ae){"use strict";var Ht=y();function Yt(e){return i;function i(){var r,t,s,n;for(t=this[Ht],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ca("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}dr.exports=ga});var Tr=u(function(Hu,wr){"use strict";var pa=require("@stdlib/assert-is-string").isPrimitive,ya=require("@stdlib/string-format");function ma(e,i){return pa(e)?null:new TypeError(ya("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}wr.exports=ma});var Or=u(function(Yu,xr){"use strict";var qa=require("@stdlib/assert-is-positive-integer").isPrimitive,ha=require("@stdlib/string-format");function da(e,i){return qa(e)?null:new TypeError(ha("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}xr.exports=da});var Ir=u(function($u,br){"use strict";var Ea=require("@stdlib/assert-is-boolean").isPrimitive,wa=require("@stdlib/string-format");function Ta(e,i){return Ea(e)?null:new TypeError(wa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}br.exports=Ta});var Ar=u(function(Xu,Sr){"use strict";var xa=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Sr.exports=xa});var Vr=u(function(Ku,Nr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format"),Sa=ie(),Fr=Ar();function Aa(e){return Oa(Fr,e)||Sa(e)?null:new TypeError(Ia('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",ba(Fr,", "),e))}Nr.exports=Aa});var Rr=u(function(Qu,Pr){"use strict";var Fa=require("@stdlib/array-base-assert-contains"),Na=require("@stdlib/array-base-join"),Va=require("@stdlib/string-format");function Pa(e){return i;function i(r,t){return Fa(e,r)?null:new TypeError(Va('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,Na(e,", "),r))}}Pr.exports=Pa});var _r=u(function(Zu,Lr){"use strict";function Ra(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Lr.exports=Ra});var Dr=u(function(ju,Br){"use strict";var La=require("@stdlib/ndarray-base-bytes-per-element");function _a(e){var i;return e.isStructType?i=e.type.byteLength:i=La(e.type),e.length&&(i*=e.length),i}Br.exports=_a});var Cr=u(function(eo,Ur){"use strict";var Ba=["none","safe","mostly-safe","same-kind","unsafe"];Ur.exports=Ba});var kr=u(function(ro,Mr){"use strict";var Da={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Mr.exports=Da});var ne=u(function(to,Gr){"use strict";var Ua=require("@stdlib/assert-has-property"),Ca=require("@stdlib/array-base-join"),Ma=require("@stdlib/utils-constant-function"),ka=require("@stdlib/string-format"),Ja=mr(),za=ie(),Ga=Er(),Wa=Tr(),Ha=Or(),Jr=Ir(),Ya=Vr(),$a=Rr(),Xa=_r(),Ka=Dr(),Qa=Cr(),Za=kr(),zr=["name","type"],ja={name:Ga,type:Ya,description:Wa,length:Ha,enumerable:Jr,writable:Jr,default:Ma(null),castingMode:$a(Qa)};function es(e,i){var r,t,s,n,a;for(r=Xa(),a=0;ai&&(i=r);return i}Wr.exports=rs});var $r=u(function(no,Yr){"use strict";var ts=require("@stdlib/assert-is-object"),Hr=require("@stdlib/assert-has-property"),se=require("@stdlib/string-format"),is=P(),ns=te(),as=ne(),ss=ae();function us(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ue(a)&&it(n.fields,t)),a.byteOffset=s,ue(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",c=0,f=[],q=0;q0&&l.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",g){for(o=" => union: %s",v=[],R=q+1;R":F=E.type,v.push(m("%s<%s>[%u]",E.name,F,T%E.alignment)),R+=1;o=m(o,v.join(", "))}else o="";v=m(a+o,T%l.alignment),l.length?w=m(n,m("%s[%u]%s",l.type,bs(T/l.alignment),v)):w=m(n,m("%s%s",l.type,v)),f.push(m(p,x,h,w)),c+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ss(n.type.layout,t,Fs(n.byteOffset)));continue}i.push(oe("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=oe("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ct.exports=Ns});var mt=u(function(go,yt){"use strict";var Vs=require("@stdlib/assert-is-plain-object"),Ps=require("@stdlib/assert-has-own-property"),Rs=require("@stdlib/array-base-assert-contains").factory,Ls=require("@stdlib/array-base-join"),gt=require("@stdlib/string-format"),_s=lt(),Bs=fe(),pt=["none","linear","layout"],Ds=Rs(pt);function Us(e,i,r){var t;if(!Vs(r))throw new TypeError(gt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ps(r,"format")&&(t.format=r.format,!Ds(t.format)))throw new TypeError(gt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Ls(pt,", "),r.format));return t.format==="linear"?_s(e.constructor,i):t.format==="layout"?Bs(i):""}yt.exports=Us});var ht=u(function(po,qt){"use strict";var Cs=require("@stdlib/assert-is-collection"),Ms=require("@stdlib/assert-is-complex-like"),ks=require("@stdlib/assert-is-function"),Js=require("@stdlib/array-to-json"),zs=L();function Gs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!Ys(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(d(this,ve,O),b!==void 0){for(x=Ks(void 0,a.length),w={},l=0;l0?g=arguments[0]:g={},su(this,a,g)}),d(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return uu(this,a)}),v}Tt.exports=fu});var vu=xt();module.exports=vu; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57d709c..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_struct_type.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` constructor\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStructType = require( './is_struct_type.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStructType = require( './is_struct_type.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAwBA,IAAIC,GAAmB,QAAS,iCAAkC,EAC9DC,GAAiB,IAarB,SAASC,GAAWC,EAAKC,EAAS,CACjC,OAAOC,EAQP,SAASA,GAAS,CACjB,IAAIC,EAAO,KAAML,EAAe,EAChC,OAAOK,EAAMF,CAAO,EAAGD,EAAI,WAAYH,EAAiB,CACzD,CACD,CAKAD,GAAO,QAAUG,KCxDjB,IAAAK,GAAAC,EAAA,SAAAC,GAAAC,GAAA,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AQ,6EAA8EiC,CAAI,CAAE,EAElH,OAAOA,EAAKhC,EAAe,EAAE,MAC9B,CAAC,EAcDZ,EAAaoC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIO,EACJ,GAAK,CAACpC,GAAkB6B,CAAI,EAC3B,MAAM,IAAI,UAAWjC,EAAQ,6EAA8EiC,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAKhC,EAAe,EACnB,IAAIF,EAAUyC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYlB,GAA0BsB,EAAO,UAAWH,CAAO,EAiB/DjC,EAAaoC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF7B,GAAe,KAAMU,EAAQmB,CAAK,CAC1C,CAAC,EAaDpD,EAAaoC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKArC,GAAO,QAAU2B,KC/ajB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_struct_type", "__commonJSMin", "exports", "module", "isPositiveInteger", "isFunction", "isStructType", "value", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStructType", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStructType", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..73b19c4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import Z,{factory as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return Z(St,t)||Et(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",K(St,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return W(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:Q(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Z(Lt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,K(Lt,", "),t))})};function It(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function Nt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(it(i.type.layout,s,kt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Pt=tt(Bt);function Rt(t,e,n){var s;if(!st(n))throw new TypeError(m("null2V",n));if(s={format:"none"},rt(n,"format")&&(s.format=n.format,!Pt(s.format)))throw new TypeError(m("null4S","format",K(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,_(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function Dt(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,lt,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,Ot(a)&&_t(i.fields,s)),a.byteOffset=r,Ot(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isFunction from '@stdlib/assert-is-function';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` constructor\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStructType from './is_struct_type.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStructType from './is_struct_type.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isFunction","isPositiveInteger","alignment","byteLengthOf","byteOffsetOf","bufferOf","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","toJSON","struct2json"],"mappings":";;+wLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GAC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O,wDAElB,OOpcF,SAAiB2H,EAAQvD,GACxB,IAAIzF,EACA4H,EACA7F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIiH,GADJpB,EAAInC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAI0K,GAAiB1K,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAO2D,GAAY3D,EAAE2K,WAD/C3K,EAAIA,EAAE2K,UAIP1M,EAAK4H,EAAEhF,MAASb,EAEjB,OAAO/B,CACR,CPgbS2M,CAAazM,KAAM2K,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_struct_type.js b/lib/is_struct_type.js deleted file mode 100644 index 3c21ea3..0000000 --- a/lib/is_struct_type.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` constructor -*/ -function isStructType( value ) { - return ( - isFunction( value ) && - isPositiveInteger( value.alignment ) && - isPositiveInteger( value.byteLength ) && - isFunction( value.byteLengthOf ) && - isFunction( value.byteOffsetOf ) && - isFunction( value.bufferOf ) && - isFunction( value.viewOf ) - ); -} - - -// EXPORTS // - -module.exports = isStructType; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index beaea8e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStructType = require( './is_struct_type.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructType( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bb41688..0000000 --- a/lib/main.js +++ /dev/null @@ -1,501 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 051a4db..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStructType = require( './is_struct_type.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructType( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index e0c3b81..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,89 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a81076c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 0e0f9ad39f0dd6f56b111c0be938f29689b8916e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 22 Jun 2025 04:16:10 +0000 Subject: [PATCH 30/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 259f09d..beaea8e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isStructType = require( './is_struct_type.js' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 10137c8..bb41688 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -115,7 +115,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -190,7 +190,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -208,7 +208,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index 9f50475..051a4db 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -23,7 +23,7 @@ var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isStructType = require( './is_struct_type.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index ad79af6..dd2d74a 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 6765fb6f356d2f780872dfc1c4044fd2d8552e09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 22 Jun 2025 04:17:48 +0000 Subject: [PATCH 31/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 73b19c4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import Z,{factory as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var lt="__@@##$$@@__struct_buffer__@@$$##@@__",ft={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var dt={complex128:"float64",complex64:"float32",complex32:"float16"};function mt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[lt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return Z(St,t)||Et(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",K(St,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return W(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:Q(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Z(Lt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,K(Lt,", "),t))})};function It(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function Nt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(it(i.type.layout,s,kt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Pt=tt(Bt);function Rt(t,e,n){var s;if(!st(n))throw new TypeError(m("null2V",n));if(s={format:"none"},rt(n,"format")&&(s.format=n.format,!Pt(s.format)))throw new TypeError(m("null4S","format",K(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,_(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function Dt(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,lt,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,Ot(a)&&_t(i.fields,s)),a.byteOffset=r,Ot(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isFunction from '@stdlib/assert-is-function';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` constructor\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStructType from './is_struct_type.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStructType from './is_struct_type.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isFunction","isPositiveInteger","alignment","byteLengthOf","byteOffsetOf","bufferOf","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","toJSON","struct2json"],"mappings":";;+wLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,I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AAEhF,KAAMnE,EAAKC,GAEnDsN,EAAkCE,EAAGtE,EAAEhF,KAAMnE,GAE9CuB,EAAK4H,EAAEhF,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CN0XasM,CAA0BjD,EAAOkD,UAAW1B,GAiBxDa,EAAarC,EAAOkD,UAAW,YAAY,WAE1C,KAAQrM,gBAAgBmJ,GACvB,MAAM,IAAIhI,MAAO,wDAOlB,OAAOmL,GAAetM,KAAM2K,EALvBO,UAAUxL,OAAS,EAChBwL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAarC,EAAOkD,UAAW,UAAU,WACxC,KAAQrM,gBAAgBmJ,GACvB,MAAM,IAAIhI,MAAO,wDAElB,OOpcF,SAAiB2H,EAAQvD,GACxB,IAAIzF,EACA4H,EACA7F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIiH,GADJpB,EAAInC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAI0K,GAAiB1K,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAO2D,GAAY3D,EAAE2K,WAD/C3K,EAAIA,EAAE2K,UAIP1M,EAAK4H,EAAEhF,MAASb,EAEjB,OAAO/B,CACR,CPgbS2M,CAAazM,KAAM2K,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a81076c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 62e3e86ee09324befb8fc803ee234338a7d635c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 22 Jun 2025 04:18:58 +0000 Subject: [PATCH 32/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 89 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_struct_type.js | 51 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 501 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8542 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_struct_type.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 89697db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var y=u(function(cu,le){"use strict";var Ot="__@@##$$@@__struct_buffer__@@$$##@@__";le.exports=Ot});var ge=u(function(gu,ce){"use strict";var bt="Struct";ce.exports=bt});var $=u(function(pu,pe){"use strict";var It={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};pe.exports=It});var me=u(function(yu,ye){"use strict";var St=require("@stdlib/assert-is-little-endian"),At=y();function Ft(e,i){return r;function r(){var t=this[At];return t[i](e.byteOffset,St)}}ye.exports=Ft});var he=u(function(mu,qe){"use strict";var Nt=require("@stdlib/assert-is-little-endian"),Vt=require("@stdlib/boolean-ctor"),Pt=y();function Rt(e,i){return r;function r(){var t=this[Pt];return Vt(t[i](e.byteOffset,Nt))}}qe.exports=Rt});var we=u(function(qu,Ee){"use strict";var de=require("@stdlib/assert-is-little-endian"),Lt=require("@stdlib/complex-cmplx"),_t=y(),Bt={complex128:"float64",complex64:"float32",complex32:"float16"};function Dt(e,i){return r;function r(){var t=this[_t],s=t[i](e.byteOffset,de),n=t[i](e.byteOffset+e.byteLength/2,de);return Lt(s,n,Bt[e.type])}}Ee.exports=Dt});var xe=u(function(hu,Te){"use strict";var Ut=require("@stdlib/assert-is-little-endian"),Ct=y();function Mt(e,i){return r;function r(){var t=this[Ct];return t[i](e.byteOffset,Ut)}}Te.exports=Mt});var be=u(function(du,Oe){"use strict";var kt=y();function Jt(e){return i;function i(){var r=this[kt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}Oe.exports=Jt});var Se=u(function(Eu,Ie){"use strict";var zt=require("@stdlib/array-typed"),Gt=y();function Wt(e){return i;function i(){var r=this[Gt];return zt(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}Ie.exports=Wt});var Fe=u(function(wu,Ae){"use strict";var Ht=y();function Yt(e){return i;function i(){var r,t,s,n;for(t=this[Ht],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ca("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}dr.exports=ga});var Tr=u(function(Hu,wr){"use strict";var pa=require("@stdlib/assert-is-string").isPrimitive,ya=require("@stdlib/string-format");function ma(e,i){return pa(e)?null:new TypeError(ya("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}wr.exports=ma});var Or=u(function(Yu,xr){"use strict";var qa=require("@stdlib/assert-is-positive-integer").isPrimitive,ha=require("@stdlib/string-format");function da(e,i){return qa(e)?null:new TypeError(ha("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}xr.exports=da});var Ir=u(function($u,br){"use strict";var Ea=require("@stdlib/assert-is-boolean").isPrimitive,wa=require("@stdlib/string-format");function Ta(e,i){return Ea(e)?null:new TypeError(wa("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}br.exports=Ta});var Ar=u(function(Xu,Sr){"use strict";var xa=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Sr.exports=xa});var Vr=u(function(Ku,Nr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format"),Sa=ie(),Fr=Ar();function Aa(e){return Oa(Fr,e)||Sa(e)?null:new TypeError(Ia('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",ba(Fr,", "),e))}Nr.exports=Aa});var Rr=u(function(Qu,Pr){"use strict";var Fa=require("@stdlib/array-base-assert-contains"),Na=require("@stdlib/array-base-join"),Va=require("@stdlib/string-format");function Pa(e){return i;function i(r,t){return Fa(e,r)?null:new TypeError(Va('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,Na(e,", "),r))}}Pr.exports=Pa});var _r=u(function(Zu,Lr){"use strict";function Ra(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Lr.exports=Ra});var Dr=u(function(ju,Br){"use strict";var La=require("@stdlib/ndarray-base-bytes-per-element");function _a(e){var i;return e.isStructType?i=e.type.byteLength:i=La(e.type),e.length&&(i*=e.length),i}Br.exports=_a});var Cr=u(function(eo,Ur){"use strict";var Ba=["none","safe","mostly-safe","same-kind","unsafe"];Ur.exports=Ba});var kr=u(function(ro,Mr){"use strict";var Da={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Mr.exports=Da});var ne=u(function(to,Gr){"use strict";var Ua=require("@stdlib/assert-has-property"),Ca=require("@stdlib/array-base-join"),Ma=require("@stdlib/utils-constant-function"),ka=require("@stdlib/string-format"),Ja=mr(),za=ie(),Ga=Er(),Wa=Tr(),Ha=Or(),Jr=Ir(),Ya=Vr(),$a=Rr(),Xa=_r(),Ka=Dr(),Qa=Cr(),Za=kr(),zr=["name","type"],ja={name:Ga,type:Ya,description:Wa,length:Ha,enumerable:Jr,writable:Jr,default:Ma(null),castingMode:$a(Qa)};function es(e,i){var r,t,s,n,a;for(r=Xa(),a=0;ai&&(i=r);return i}Wr.exports=rs});var $r=u(function(no,Yr){"use strict";var ts=require("@stdlib/assert-is-object"),Hr=require("@stdlib/assert-has-property"),se=require("@stdlib/string-format"),is=P(),ns=te(),as=ne(),ss=ae();function us(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ue(a)&&it(n.fields,t)),a.byteOffset=s,ue(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",c=0,f=[],q=0;q0&&l.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",g){for(o=" => union: %s",v=[],R=q+1;R":F=E.type,v.push(m("%s<%s>[%u]",E.name,F,T%E.alignment)),R+=1;o=m(o,v.join(", "))}else o="";v=m(a+o,T%l.alignment),l.length?w=m(n,m("%s[%u]%s",l.type,bs(T/l.alignment),v)):w=m(n,m("%s%s",l.type,v)),f.push(m(p,x,h,w)),c+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ss(n.type.layout,t,Fs(n.byteOffset)));continue}i.push(oe("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=oe("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ct.exports=Ns});var mt=u(function(go,yt){"use strict";var Vs=require("@stdlib/assert-is-plain-object"),Ps=require("@stdlib/assert-has-own-property"),Rs=require("@stdlib/array-base-assert-contains").factory,Ls=require("@stdlib/array-base-join"),gt=require("@stdlib/string-format"),_s=lt(),Bs=fe(),pt=["none","linear","layout"],Ds=Rs(pt);function Us(e,i,r){var t;if(!Vs(r))throw new TypeError(gt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ps(r,"format")&&(t.format=r.format,!Ds(t.format)))throw new TypeError(gt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Ls(pt,", "),r.format));return t.format==="linear"?_s(e.constructor,i):t.format==="layout"?Bs(i):""}yt.exports=Us});var ht=u(function(po,qt){"use strict";var Cs=require("@stdlib/assert-is-collection"),Ms=require("@stdlib/assert-is-complex-like"),ks=require("@stdlib/assert-is-function"),Js=require("@stdlib/array-to-json"),zs=L();function Gs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!Ys(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(d(this,ve,O),b!==void 0){for(x=Ks(void 0,a.length),w={},l=0;l0?g=arguments[0]:g={},su(this,a,g)}),d(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return uu(this,a)}),v}Tt.exports=fu});var vu=xt();module.exports=vu; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57d709c..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_struct_type.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` constructor\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar isStructType = require( './is_struct_type.js' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isStructType = require( './is_struct_type.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAwBA,IAAIC,GAAmB,QAAS,iCAAkC,EAC9DC,GAAiB,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,IAAIC,EAAMhC,EAAYU,EAAaqB,CAAK,EACxC,GAAKC,aAAe,MACnB,MAAMA,EAEP,OAAOjB,EAAQiB,CAAI,EAAE,IACtB,CAAC,EAcDlD,EAAaoC,EAAQ,WAAY,SAAmBQ,EAAM,CACzD,GAAK,CAAC7B,GAAkB6B,CAAI,EAC3B,MAAM,IAAI,UAAWjC,EAAQ,6EAA8EiC,CAAI,CAAE,EAElH,OAAOA,EAAKhC,EAAe,EAAE,MAC9B,CAAC,EAcDZ,EAAaoC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIO,EACJ,GAAK,CAACpC,GAAkB6B,CAAI,EAC3B,MAAM,IAAI,UAAWjC,EAAQ,6EAA8EiC,CAAI,CAAE,EAElH,OAAAO,EAAMP,EAAKhC,EAAe,EACnB,IAAIF,EAAUyC,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDnB,EAAYlB,GAA0BsB,EAAO,UAAWH,CAAO,EAiB/DjC,EAAaoC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF7B,GAAe,KAAMU,EAAQmB,CAAK,CAC1C,CAAC,EAaDpD,EAAaoC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKArC,GAAO,QAAU2B,KC/ajB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_struct_type", "__commonJSMin", "exports", "module", "isPositiveInteger", "isFunction", "isStructType", "value", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "contains", "join", "format", "isStructType", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "hasProp", "join", "constantFunction", "format", "hasProperties", "isStructType", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..365bc4e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as J}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ft="__@@##$$@@__struct_buffer__@@$$##@@__",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ft]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Lt,t)||Tt(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",Q(Lt,", "),t))},description:function(t,e){return Z(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return X(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:St,writable:St,default:W(null),castingMode:(Vt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Vt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Q(Vt,", "),t))})};function Jt(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function Mt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(ot(i.type.layout,s,Pt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Rt=et(Bt);function Dt(t,e,n){var s;if(!rt(n))throw new TypeError(m("null2V",n));if(s={format:"none"},it(n,"format")&&(s.format=n.format,!Rt(s.format)))throw new TypeError(m("null4S","format",Q(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,at(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function $t(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,ft,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,Et(a)&&At(i.fields,s)),a.byteOffset=r,Et(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isFunction from '@stdlib/assert-is-function';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` constructor\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStructType from './is_struct_type.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStructType from './is_struct_type.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isFunction","isPositiveInteger","alignment","byteLengthOf","byteOffsetOf","bufferOf","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","toJSON","struct2json"],"mappings":";;w5LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV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S,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CN0XasM,CAA0BjD,EAAOkD,UAAW1B,GAiBxDa,EAAarC,EAAOkD,UAAW,YAAY,WAE1C,KAAQrM,gBAAgBmJ,GACvB,MAAM,IAAIhI,MAAO,wDAOlB,OAAOmL,GAAetM,KAAM2K,EALvBO,UAAUxL,OAAS,EAChBwL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAarC,EAAOkD,UAAW,UAAU,WACxC,KAAQrM,gBAAgBmJ,GACvB,MAAM,IAAIhI,MAAO,wDAElB,OOpcF,SAAiB2H,EAAQvD,GACxB,IAAIzF,EACA4H,EACA7F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIiH,GADJpB,EAAInC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAI0K,GAAiB1K,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAO2D,EAAY3D,EAAE2K,WAD/C3K,EAAIA,EAAE2K,UAIP1M,EAAK4H,EAAEhF,MAASb,EAEjB,OAAO/B,CACR,CPgbS2M,CAAazM,KAAM2K,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_struct_type.js b/lib/is_struct_type.js deleted file mode 100644 index 3c21ea3..0000000 --- a/lib/is_struct_type.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` constructor -*/ -function isStructType( value ) { - return ( - isFunction( value ) && - isPositiveInteger( value.alignment ) && - isPositiveInteger( value.byteLength ) && - isFunction( value.byteLengthOf ) && - isFunction( value.byteOffsetOf ) && - isFunction( value.bufferOf ) && - isFunction( value.viewOf ) - ); -} - - -// EXPORTS // - -module.exports = isStructType; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index beaea8e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isStructType = require( './is_struct_type.js' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructType( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bb41688..0000000 --- a/lib/main.js +++ /dev/null @@ -1,501 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 051a4db..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isStructType = require( './is_struct_type.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructType( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index dd2d74a..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,89 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -130,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4409595 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 7f23534aa0d79d04c526bdb6ce1b7dc0c7fc893a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Jun 2025 23:47:26 +0000 Subject: [PATCH 33/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 10137c8..bb41688 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -115,7 +115,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -190,7 +190,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -208,7 +208,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 740249b..b84a333 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From fad8e7bddc32b85213bda6e8a128da202d715837 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Jun 2025 23:47:46 +0000 Subject: [PATCH 34/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 365bc4e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.1-esm/index.mjs";import{isPrimitive as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as J}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ft="__@@##$$@@__struct_buffer__@@$$##@@__",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ft]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Lt,t)||Tt(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",Q(Lt,", "),t))},description:function(t,e){return Z(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return X(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:St,writable:St,default:W(null),castingMode:(Vt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Vt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Q(Vt,", "),t))})};function Jt(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function Mt(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(ot(i.type.layout,s,Pt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Rt=et(Bt);function Dt(t,e,n){var s;if(!rt(n))throw new TypeError(m("null2V",n));if(s={format:"none"},it(n,"format")&&(s.format=n.format,!Rt(s.format)))throw new TypeError(m("null4S","format",Q(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,at(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function $t(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,ft,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,Et(a)&&At(i.fields,s)),a.byteOffset=r,Et(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport isFunction from '@stdlib/assert-is-function';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` constructor\n*/\nfunction isStructType( value ) {\n\treturn (\n\t\tisFunction( value ) &&\n\t\tisPositiveInteger( value.alignment ) &&\n\t\tisPositiveInteger( value.byteLength ) &&\n\t\tisFunction( value.byteLengthOf ) &&\n\t\tisFunction( value.byteOffsetOf ) &&\n\t\tisFunction( value.bufferOf ) &&\n\t\tisFunction( value.viewOf )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isStructType from './is_struct_type.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructType( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isStructType from './is_struct_type.js';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructType( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isFunction","isPositiveInteger","alignment","byteLengthOf","byteOffsetOf","bufferOf","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","join","description","enumerable","writable","default","constantFunction","normalize","keys","err","k","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","toJSON","struct2json"],"mappings":";;w5LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjDT,GAAUH,EAAIQ,WAEf,OAAOH,CACP,CACF,CDdUQ,CAAgBb,GET1B,SAAwBA,GACvB,OAQA,W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P1M,EAAK4H,EAAEhF,MAASb,EAEjB,OAAO/B,CACR,CPgbS2M,CAAazM,KAAM2K,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4409595..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2e5df17cb4955ab1ffb5dec00a51c53632821a90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Jun 2025 23:48:35 +0000 Subject: [PATCH 35/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 90 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 501 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 99 files changed, 4863 insertions(+), 8493 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 38a72fb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(uu,fe){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";fe.exports=Et});var le=u(function(ou,ve){"use strict";var wt="Struct";ve.exports=wt});var Y=u(function(fu,ce){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ce.exports=Tt});var pe=u(function(vu,ge){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}ge.exports=bt});var ye=u(function(lu,me){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}me.exports=Ft});var de=u(function(cu,he){"use strict";var qe=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Pt={complex128:"float64",complex64:"float32",complex32:"float16"};function Rt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,qe),n=t[i](e.byteOffset+e.byteLength/2,qe);return Nt(s,n,Pt[e.type])}}he.exports=Rt});var we=u(function(gu,Ee){"use strict";var Lt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Lt)}}Ee.exports=Bt});var xe=u(function(pu,Te){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}Te.exports=Ut});var be=u(function(mu,Oe){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}Oe.exports=kt});var Se=u(function(yu,Ie){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}mr.exports=oa});var hr=u(function(Mu,qr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}qr.exports=la});var Er=u(function(ku,dr){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}dr.exports=pa});var Tr=u(function(Ju,wr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}wr.exports=qa});var Or=u(function(zu,xr){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];xr.exports=ha});var Sr=u(function(Gu,Ir){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),br=Or();function xa(e){return Ea(br,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(br,", "),e))}Ir.exports=xa});var Fr=u(function(Wu,Ar){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Ar.exports=Sa});var Vr=u(function(Hu,Nr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Nr.exports=Aa});var Rr=u(function(Yu,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var _r=u(function($u,Lr){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];Lr.exports=Va});var Dr=u(function(Xu,Br){"use strict";var Pa={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Br.exports=Pa});var te=u(function(Ku,Mr){"use strict";var Ra=require("@stdlib/assert-is-struct-constructor-like"),La=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=pr(),Ca=yr(),Ma=hr(),ka=Er(),Ur=Tr(),Ja=Sr(),za=Fr(),Ga=Vr(),Wa=Rr(),Ha=_r(),Ya=Dr(),Cr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Ur,writable:Ur,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}kr.exports=Ka});var Gr=u(function(Zu,zr){"use strict";var Qa=require("@stdlib/assert-is-object"),Jr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=P(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&jr(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",c=0,f=[],q=0;q0&&l.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",g){for(o=" => union: %s",v=[],R=q+1;R":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),R+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%l.alignment),l.length?w=y(n,y("%s[%u]%s",l.type,Es(T/l.alignment),v)):w=y(n,y("%s%s",l.type,v)),f.push(y(p,x,h,w)),c+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ot.exports=bs});var ct=u(function(uo,lt){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),ft=require("@stdlib/string-format"),Ns=ut(),Vs=ue(),vt=["none","linear","layout"],Ps=As(vt);function Rs(e,i,r){var t;if(!Is(r))throw new TypeError(ft("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ps(t.format)))throw new TypeError(ft('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(vt,", "),r.format));return t.format==="linear"?Ns(e.constructor,i):t.format==="layout"?Vs(i):""}lt.exports=Rs});var pt=u(function(oo,gt){"use strict";var Ls=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=L();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!Js(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(d(this,oe,O),b!==void 0){for(x=Ws(void 0,a.length),w={},l=0;l0?g=arguments[0]:g={},ru(this,a,g)}),d(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return tu(this,a)}),v}ht.exports=nu});var au=dt();module.exports=au; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index da012c6..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,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oC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIgB,EACJ,GAAK,EAAG,gBAAgBhB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBgB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF7B,GAAe,KAAMU,EAAQmB,CAAK,CAC1C,CAAC,EAaDpD,EAAaoC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKArC,GAAO,QAAU2B,KC/ajB,IAAI2B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b7bdd61 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{factory as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(Et,t)||C(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",X(Et,", "),t))},description:function(t,e){return K(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:H(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return W(Tt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,X(Tt,", "),t))})};function Ft(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function It(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,kt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],At=nt(_t);function Bt(t,e,n){var s;if(!tt(n))throw new TypeError(m("null2V",n));if(s={format:"none"},et(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(m("null4S","format",X(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,N(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function Pt(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,ot,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;iwLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA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,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPgbSyM,CAAavM,KAAMwK,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bb41688..0000000 --- a/lib/main.js +++ /dev/null @@ -1,501 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index b84a333..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "github:stdlib-js/assert-is-struct-constructor-like#main", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3abf868 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From ea19ba776dedf4bf2d2751e5e942d4e28707e16d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 24 Jun 2025 01:51:51 +0000 Subject: [PATCH 36/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 25c94cf..bdbbdbe 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 740249b..b84a333 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 27e1b19f2007a191ad05ebb6d4f9c92a173bd66d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 24 Jun 2025 01:52:23 +0000 Subject: [PATCH 37/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b7bdd61..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{factory as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(m("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(Et,t)||C(t)?null:new TypeError(m('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",X(Et,", "),t))},description:function(t,e){return K(t)?null:new TypeError(m("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(m("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:H(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return W(Tt,t)?null:new TypeError(m('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,X(Tt,", "),t))})};function Ft(t,e){var n,s,r,i,o;for(n={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},o=0;oe&&(e=n);return e}function It(t){var e,n,s,r,o,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,kt(i.byteOffset))):e.push(m("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=m("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],At=nt(_t);function Bt(t,e,n){var s;if(!tt(n))throw new TypeError(m("null2V",n));if(s={format:"none"},et(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(m("null4S","format",X(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,u,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",u=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(m("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=m(a,l.join(", "))}else a="";l=m(i+a,O%v.alignment),g=v.length?m(r,m("%s[%u]%s",v.type,N(O/v.alignment),l)):m(r,m("%s%s",v.type,l)),f.push(m(o,p,c,g)),u+=1}for(O=0;O"}function Pt(g){var h,y,b,v,j,w,x,O;if(!s(g))throw new TypeError(m("null2O",g));if(x=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!i(e))throw new TypeError(m("null3L",e));x=e}if(t(this,ot,v),void 0!==x){for(p=l(void 0,w.length),g={},S=0;S0&&((i=t[l-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(E.prototype,"toJSON",(function(){if(!(this instanceof E))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,r,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;iwLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,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C,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPgbSyM,CAAavM,KAAMwK,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3abf868..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d870ea7562a46fafe1e423a12f290ffbbb06fcba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 24 Jun 2025 01:52:53 +0000 Subject: [PATCH 38/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 92 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 99 files changed, 4863 insertions(+), 8517 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c206864..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e.constructor,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(this,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index a1b8508..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,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OR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f446d30 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as H}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var at="__@@##$$@@__struct_buffer__@@$$##@@__",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[at]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Ot,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",C(Ot,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(W("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:G(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,C(Et,", "),t))})};function Vt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,Nt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],kt=Y(_t);function At(t,e,n){var s;if(!et(n))throw new TypeError(u("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!kt(s.format)))throw new TypeError(u("null4S","format",C(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,N(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Pt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,at,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,wt(a)&&Jt(i.fields,s)),a.byteOffset=r,wt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;8nLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjDT,GAAUH,EAAIQ,WAEf,OAAOH,CACP,CACF,CDdUQ,CAAgBb,GET1B,SAAwBA,GACvB,OAQA,WACC,IAAII,EAAOG,KAAM5B,IACjB,OAAOmC,EAAYV,EAA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deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bdbbdbe..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index b84a333..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "github:stdlib-js/assert-is-struct-constructor-like#main", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0e160bd --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 667bdf1d8ec022aa76e495393a214c2f665a7c25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 02:24:44 +0000 Subject: [PATCH 39/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 25c94cf..bdbbdbe 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index ab8ca66..870fe6b 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 740249b..b84a333 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 1ae8e75e589a62e2b8073546eef1b39f022bc851 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 03:23:02 +0000 Subject: [PATCH 40/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f446d30..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as H}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var at="__@@##$$@@__struct_buffer__@@$$##@@__",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[at]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Ot,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",C(Ot,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(W("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:G(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,C(Et,", "),t))})};function Vt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,Nt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],kt=Y(_t);function At(t,e,n){var s;if(!et(n))throw new TypeError(u("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!kt(s.format)))throw new TypeError(u("null4S","format",C(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,N(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Pt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,at,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,wt(a)&&Jt(i.fields,s)),a.byteOffset=r,wt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;8nLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CAC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CAA0BjD,EAAOkD,UAAW1B,GAiBxDa,EAAarC,EAAOkD,UAAW,YAAY,WAE1C,KAAQlM,gBAAgBgJ,GACvB,MAAM,IAAI7H,MAAO,wDAOlB,OAAOgL,GAAenM,KAAMwK,EALvBO,UAAUrL,OAAS,EAChBqL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAarC,EAAOkD,UAAW,UAAU,WACxC,KAAQlM,gBAAgBgJ,GACvB,MAAM,IAAI7H,MAAO,wDAElB,OO1dF,SAAiBwH,EAAQpD,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAI8G,GADJpB,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMwK,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0e160bd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 23f1cefbe6f1bcd921d878a344568821ac31cb5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 03:23:32 +0000 Subject: [PATCH 41/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 92 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8518 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 29621e7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T02:01:38.608Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c206864..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e.constructor,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(this,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index a1b8508..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAA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jE,CAAC,EAGDpB,EAAYlB,GAA0BsB,EAAO,UAAWH,CAAO,EAiB/DlC,EAAaqC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIiB,EACJ,GAAK,EAAG,gBAAgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAe,KAAMU,EAAQoB,CAAK,CAC1C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d216b03 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import et,{factory as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var dt="__@@##$$@@__struct_buffer__@@$$##@@__",mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ut={complex128:"float64",complex64:"float32",complex32:"float16"};function pt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[dt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return et(Lt,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",X(Lt,", "),t))},description:function(t,e){return Z(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return tt(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:St,writable:St,default:Y(null),castingMode:(Vt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return et(Vt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,X(Vt,", "),t))})};function Jt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function kt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(ot(i.type.layout,s,At(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Rt=nt(Bt);function Dt(t,e,n){var s;if(!it(n))throw new TypeError(u("null2V",n));if(s={format:"none"},at(n,"format")&&(s.format=n.format,!Rt(s.format)))throw new TypeError(u("null4S","format",X(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,P(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function $t(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,dt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Tt(a)&&_t(i.fields,s)),a.byteOffset=r,Tt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;8+LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO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AEnB,SACN0F,EAAsBD,EAAGtE,EAAE7E,KAAMnE,EAAKC,GAEtCuN,EAAqBF,EAAGtE,EAAE7E,KAAMnE,GAEtBgJ,EAAEnB,SACb4F,EAAmCH,EAAGtE,EAAE7E,KAAMnE,EAAKC,GAEnDmN,EAAkCE,EAAGtE,EAAE7E,KAAMnE,GAE9CuB,EAAKyH,EAAE7E,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZamM,CAA0BjD,EAAOkD,UAAW1B,GAiBxDa,EAAarC,EAAOkD,UAAW,YAAY,WAE1C,KAAQlM,gBAAgBgJ,GACvB,MAAM,IAAI7H,MAAO,wDAOlB,OAAOgL,GAAenM,KAAMwK,EALvBO,UAAUrL,OAAS,EAChBqL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAarC,EAAOkD,UAAW,UAAU,WACxC,KAAQlM,gBAAgBgJ,GACvB,MAAM,IAAI7H,MAAO,wDAElB,OO1dF,SAAiBwH,EAAQpD,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAI8G,GADJpB,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMwK,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bdbbdbe..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( this, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index 870fe6b..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a `struct` instance to a string. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( struct.constructor, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index b84a333..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "github:stdlib-js/assert-is-struct-constructor-like#main", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b16ad79 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From d78b4b74d17d77769c163304181e8974f82c7850 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 21 Sep 2025 09:37:47 +0000 Subject: [PATCH 42/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 740249b..b84a333 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From f4321301b19ac050882e084cdd0e81458ff550aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 21 Sep 2025 09:38:02 +0000 Subject: [PATCH 43/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d216b03..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import et,{factory as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var dt="__@@##$$@@__struct_buffer__@@$$##@@__",mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ut={complex128:"float64",complex64:"float32",complex32:"float16"};function pt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[dt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return et(Lt,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",X(Lt,", "),t))},description:function(t,e){return Z(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return tt(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:St,writable:St,default:Y(null),castingMode:(Vt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return et(Vt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,X(Vt,", "),t))})};function Jt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function kt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(ot(i.type.layout,s,At(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Rt=nt(Bt);function Dt(t,e,n){var s;if(!it(n))throw new TypeError(u("null2V",n));if(s={format:"none"},at(n,"format")&&(s.format=n.format,!Rt(s.format)))throw new TypeError(u("null4S","format",X(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,P(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function $t(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,dt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Tt(a)&&_t(i.fields,s)),a.byteOffset=r,Tt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to a string.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( struct.constructor, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( this, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","struct","options","opts","isPlainObject","hasOwnProp","Struct","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;8+LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,O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S,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZamM,CAA0BjD,EAAOkD,UAAW1B,GAiBxDa,EAAarC,EAAOkD,UAAW,YAAY,WAE1C,KAAQlM,gBAAgBgJ,GACvB,MAAM,IAAI7H,MAAO,wDAOlB,OAAOgL,GAAenM,KAAMwK,EALvBO,UAAUrL,OAAS,EAChBqL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAarC,EAAOkD,UAAW,UAAU,WACxC,KAAQlM,gBAAgBgJ,GACvB,MAAM,IAAI7H,MAAO,wDAElB,OO1dF,SAAiBwH,EAAQpD,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAI8G,GADJpB,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMwK,EAC5B,IAEQxB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b16ad79..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 979cc0fcca39848aa1f708be0d6b5d45d852127f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 21 Sep 2025 09:38:50 +0000 Subject: [PATCH 44/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 93 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 99 files changed, 4863 insertions(+), 8523 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAA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J,GAAK,EAAG,gBAAgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9f7db4b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ft="__@@##$$@@__struct_buffer__@@$$##@@__",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ft]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(St,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",W(St,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Z(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:X(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,W(Lt,", "),t))})};function It(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Nt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(at(i.type.layout,s,Pt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var At=["none","linear","layout"],Bt=et(At);function Rt(t,e,n){var s;if(!rt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},it(n,"format")&&(s.format=n.format,!Bt(s.format)))throw new TypeError(u("null4S","format",W(At,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,A(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Dt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ft,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Et(a)&&Mt(i.fields,s)),a.byteOffset=r,Et(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;q9LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eA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E,KAAMnE,EAAKC,GAEnDkN,EAAkCE,EAAGrE,EAAE7E,KAAMnE,GAE9CuB,EAAKyH,EAAE7E,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZakM,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index b84a333..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "github:stdlib-js/assert-is-struct-constructor-like#main", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5a037e2 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 90998300968e429ded294642e2a141d12c02fca8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 00:43:33 +0000 Subject: [PATCH 45/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 740249b..b84a333 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 9cf433d029bb7405e93b9bae678cfc12ab8acef7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 00:44:47 +0000 Subject: [PATCH 46/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9f7db4b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.2-esm/index.mjs";import tt,{factory as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ft="__@@##$$@@__struct_buffer__@@$$##@@__",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ft]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(St,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",W(St,", "),t))},description:function(t,e){return Y(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Z(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:X(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,W(Lt,", "),t))})};function It(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Nt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(at(i.type.layout,s,Pt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var At=["none","linear","layout"],Bt=et(At);function Rt(t,e,n){var s;if(!rt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},it(n,"format")&&(s.format=n.format,!Bt(s.format)))throw new TypeError(u("null4S","format",W(At,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,A(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Dt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ft,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Et(a)&&Mt(i.fields,s)),a.byteOffset=r,Et(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;q9LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,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AO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5a037e2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 89ec87c4d861d1d1c27dfbc701a35e3a8475530e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 00:45:12 +0000 Subject: [PATCH 47/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 93 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 111 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8524 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ff0a178..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-12-29T00:42:40.301Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,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BAAgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ff18ffd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Y,{factory as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return Y(Et,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",K(Et,", "),t))},description:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return X(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:Q(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Y(Tt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,K(Tt,", "),t))})};function Ft(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function It(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(rt(i.type.layout,s,Mt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var kt=["none","linear","layout"],At=Z(kt);function Pt(t,e,n){var s;if(!nt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},st(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(u("null4S","format",K(kt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,k(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Bt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ot,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;muLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IA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WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index b84a333..8d12523 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.2.2", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "github:stdlib-js/assert-is-struct-constructor-like#main", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", @@ -131,7 +25,6 @@ "type", "dataview" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b44796e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 452c085b2fc0b98bd4484760c3f1c4d0ba4204b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 06:47:58 +0000 Subject: [PATCH 48/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index a17ebee..ee5aa36 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.2", "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-constant-function": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 932f77f87c300170fb6ff2b89f04adc366f38d9d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:48:26 +0000 Subject: [PATCH 49/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ff18ffd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.2-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Y,{factory as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return Y(Et,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",K(Et,", "),t))},description:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return X(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:Q(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Y(Tt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,K(Tt,", "),t))})};function Ft(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function It(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(rt(i.type.layout,s,Mt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var kt=["none","linear","layout"],At=Z(kt);function Pt(t,e,n){var s;if(!nt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},st(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(u("null4S","format",K(kt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,k(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Bt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ot,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;muLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EA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AIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b44796e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 817018e9462b422b5d7017acdf46fceca3c50b6a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:48:48 +0000 Subject: [PATCH 50/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 93 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 99 files changed, 4863 insertions(+), 8622 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAA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EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..35f2178 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.0-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.2-esm/index.mjs";import{isPrimitive as H}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Q,{factory as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.0-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.0-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.2-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var at="__@@##$$@@__struct_buffer__@@$$##@@__",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[at]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return Q(Ot,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",C(Ot,", "),t))},description:function(t,e){return H(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:G(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Q(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,C(Et,", "),t))})};function Vt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(nt(i.type.layout,s,Nt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Mt=["none","linear","layout"],_t=W(Mt);function At(t,e,n){var s;if(!Z(n))throw new TypeError(u("null2V",n));if(s={format:"none"},tt(n,"format")&&(s.format=n.format,!_t(s.format)))throw new TypeError(u("null4S","format",C(Mt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,et(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Bt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,at,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,wt(a)&&Jt(i.fields,s)),a.byteOffset=r,wt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;wmLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EAC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QK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index ee5aa36..14cda40 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.3.0", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "github:stdlib-js/array-base-map#main", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.1", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "^0.1.0", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.2", - "@stdlib/blas-ext-base-gfill": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.0", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/utils-define-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.1.0", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34b7b26 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 4b63fb3e06a0911c59d93f42b41793c247865a02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:17:57 +0000 Subject: [PATCH 51/84] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index af1892b..7954af0 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import struct from 'https://cdn.jsdelivr.net/gh/stdlib-js/dstructs-struct@esm/index.mjs'; +import struct from 'https://cdn.jsdelivr.net/gh/stdlib-js/dstructs-struct@v0.1.0-esm/index.mjs'; ``` #### struct( schema ) @@ -146,7 +146,7 @@ TODO: document constructor API - - - - From a76697e70692c149f79df6b51d876d0cf4265d70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 04:31:03 +0000 Subject: [PATCH 55/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 93 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8623 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 03d08d6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-02T02:48:29.065Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,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GAAK,EAAG,gBAAgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7acdce9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.0-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W,{factory as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.0-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(Et,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",G(Et,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:H(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return W(Tt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,G(Tt,", "),t))})};function Ft(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function It(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,kt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],At=X(_t);function Bt(t,e,n){var s;if(!tt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},et(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(u("null4S","format",G(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,nt(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Pt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ot,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;0rLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,C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vB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 33bb33f..14cda40 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.0", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.2", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.1", - "@stdlib/array-base-filled": "^0.2.2", - "@stdlib/array-base-index-of": "^0.3.0", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-map": "^0.1.0", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-min-dtype": "^0.3.0", - "@stdlib/array-to-json": "^0.3.0", - "@stdlib/array-typed": "^0.3.1", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-bigint": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.3", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/assert-is-struct-constructor-like": "^0.1.0", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/blas-base-gcopy": "^0.2.2", - "@stdlib/blas-ext-base-gfill": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-cmplx": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/math-base-special-fast-min": "^0.3.0", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.0", - "@stdlib/number-ctor": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/complex-float64-ctor": "^0.1.1", - "@stdlib/number-float64-base-to-words": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..da67165 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From e35187338132b1edf63f949d3413953062fddd97 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:11:08 +0000 Subject: [PATCH 56/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index f82b42b..cc93f4e 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 60b8f86a0ad5a549160c0853deed9bed1df5e93d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:06:17 +0000 Subject: [PATCH 57/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7acdce9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.0-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.2-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W,{factory as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.2-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.0-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.0-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(Et,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",G(Et,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:H(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return W(Tt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,G(Tt,", "),t))})};function Ft(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function It(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,kt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],At=X(_t);function Bt(t,e,n){var s;if(!tt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},et(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(u("null4S","format",G(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,nt(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Pt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ot,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;0rLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjDT,GAAUH,EAAIQ,WAEf,OAAOH,CACP,CACF,CDdUQ,CAAgBb,GET1B,SAAwBA,GACv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} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index da67165..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 519d95ee6c395b78585ade33ff4b90320cb2b06a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:06:43 +0000 Subject: [PATCH 58/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 99 files changed, 4863 insertions(+), 8625 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,I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in", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c57add8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@v0.2.3-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as M}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as tt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as et}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{factory as lt}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import pt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var ct="__@@##$$@@__struct_buffer__@@$$##@@__",gt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ht={complex128:"float64",complex64:"float32",complex32:"float16"};function yt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ct]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return nt(It,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",st(It,", "),t))},description:function(t,e){return tt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return et(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ut,writable:Ut,default:Z(null),castingMode:(Jt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return nt(Jt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Y(Jt,", "),t))})};function Pt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function At(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(dt(i.type.layout,s,Dt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var zt=["none","linear","layout"],qt=lt(zt);function Ct(t,e,n){var s;if(!at(n))throw new TypeError(u("null2V",n));if(s={format:"none"},ot(n,"format")&&(s.format=n.format,!qt(s.format)))throw new TypeError(u("null4S","format",Y(zt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,ft(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Gt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ct,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Ft(a)&&Rt(i.fields,s)),a.byteOffset=r,Ft(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;y+MAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC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M,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index cc93f4e..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.0", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c0e447a --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From b65f2cf5b0117e543be0ac7a6212e33c6fe19500 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:35:34 +0000 Subject: [PATCH 59/84] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ca4842..03e744b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import struct from 'https://cdn.jsdelivr.net/gh/stdlib-js/dstructs-struct@esm/index.mjs'; +import struct from 'https://cdn.jsdelivr.net/gh/stdlib-js/dstructs-struct@v0.1.1-esm/index.mjs'; ``` #### struct( schema ) @@ -146,7 +146,7 @@ TODO: document constructor API - - - - From dddc544425dd4bb5d928b7aad2867e79c50ba32b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 04:09:06 +0000 Subject: [PATCH 63/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8626 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1c29a3c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-16T02:11:25.766Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,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AAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9af5efb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as H}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{factory as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Et,t)||W(t)?null:new TypeError(Q('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",Y(Et,", "),t))},description:function(t,e){return H(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return K(t)?null:new TypeError(Q("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:G(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Tt,t)?null:new TypeError(Q('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Y(Tt,", "),t))})};function Ft(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function It(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(rt(i.type.layout,s,kt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],At=st(_t);function Bt(t,e,n){var s;if(!et(n))throw new TypeError(u("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(u("null4S","format",C(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,N(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Pt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ot,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;wyLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,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gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..25c6e4a --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From d1006c695dcc7d78c56c6c928c1e74b262771cd8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Mar 2026 03:13:54 +0000 Subject: [PATCH 64/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From fd14a820002ced0a8f6b6d064c7680753a2b14fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Mar 2026 04:46:51 +0000 Subject: [PATCH 65/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9af5efb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as H}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{factory as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var ot="__@@##$$@@__struct_buffer__@@$$##@@__",lt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ft={complex128:"float64",complex64:"float32",complex32:"float16"};function dt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ot]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Et,t)||W(t)?null:new TypeError(Q('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",Y(Et,", "),t))},description:function(t,e){return H(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return K(t)?null:new TypeError(Q("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ot,writable:Ot,default:G(null),castingMode:(Tt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Tt,t)?null:new TypeError(Q('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Y(Tt,", "),t))})};function Ft(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function It(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(rt(i.type.layout,s,kt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],At=st(_t);function Bt(t,e,n){var s;if(!et(n))throw new TypeError(u("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!At(s.format)))throw new TypeError(u("null4S","format",C(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,N(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Pt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ot,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,xt(a)&&Nt(i.fields,s)),a.byteOffset=r,xt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;wyLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,O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yK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 25c6e4a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3b970b3c34abadc89da5edeb03965c41a66bc9a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Mar 2026 04:47:18 +0000 Subject: [PATCH 66/84] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8626 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a38c856..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-09T02:30:56.731Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,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CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..be098ca --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.2-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.3-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import{isPrimitive as B}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import rt,{factory as it}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var pt="__@@##$$@@__struct_buffer__@@$$##@@__",ct={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var gt={complex128:"float64",complex64:"float32",complex32:"float16"};function ht(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[pt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return rt(Ut,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",tt(Ut,", "),t))},description:function(t,e){return nt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return st(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ft,writable:Ft,default:et(null),castingMode:(It=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return rt(It,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,tt(It,", "),t))})};function kt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function _t(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(dt(i.type.layout,s,Rt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var $t=["none","linear","layout"],zt=it($t);function qt(t,e,n){var s;if(!lt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},ft(n,"format")&&(s.format=n.format,!zt(s.format)))throw new TypeError(u("null4S","format",tt($t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,$(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Ct(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,pt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Vt(a)&&Bt(i.fields,s)),a.byteOffset=r,Vt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;w1MAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO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,EAAEnB,SACb2F,EAAmCH,EAAGrE,EAAE7E,KAAMnE,EAAKC,GAEnDkN,EAAkCE,EAAGrE,EAAE7E,KAAMnE,GAE9CuB,EAAKyH,EAAE7E,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZakM,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e5be40d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From f42a2ce384616e7e6f7e85f156443bf5a28cb78a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 03:59:12 +0000 Subject: [PATCH 67/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 4a17e032e78115598582460625bbaacb63c4974c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 05:48:21 +0000 Subject: [PATCH 68/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index be098ca..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.2-esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.3-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import{isPrimitive as B}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import rt,{factory as it}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var pt="__@@##$$@@__struct_buffer__@@$$##@@__",ct={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var gt={complex128:"float64",complex64:"float32",complex32:"float16"};function ht(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[pt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return rt(Ut,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",tt(Ut,", "),t))},description:function(t,e){return nt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return st(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ft,writable:Ft,default:et(null),castingMode:(It=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return rt(It,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,tt(It,", "),t))})};function kt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function _t(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(dt(i.type.layout,s,Rt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var $t=["none","linear","layout"],zt=it($t);function qt(t,e,n){var s;if(!lt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},ft(n,"format")&&(s.format=n.format,!zt(s.format)))throw new TypeError(u("null4S","format",tt($t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,$(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Ct(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,pt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Vt(a)&&Bt(i.fields,s)),a.byteOffset=r,Vt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;w1MAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM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KyH,EAAE7E,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZakM,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e5be40d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7fa1a04b685ae78966b62ff2ae7cb1ef5a5e8347 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 05:48:38 +0000 Subject: [PATCH 69/84] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8637 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 47214a4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-23T03:04:04.014Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAA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oC,CAAM,GACxBlD,GAAyBkD,EAAM,WAAY,CAG9C,CAAC,EAeDpD,EAAaqC,EAAQ,SAAU,SAAiBa,EAAO,CACtD,IAAIC,EAAMhC,EAAYU,EAAaqB,CAAK,EACxC,GAAKC,aAAe,MACnB,MAAMA,EAEP,OAAOjB,EAAQiB,CAAI,EAAE,IACtB,CAAC,EAcDnD,EAAaqC,EAAQ,SAAU,SAAiBQ,EAAM,CACrD,IAAIQ,EACJ,GAAK,CAACrC,GAAkB6B,CAAI,EAC3B,MAAM,IAAI,UAAWjC,EAAQ,6EAA8EiC,CAAI,CAAE,EAElH,OAAAQ,EAAMR,EAAKhC,EAAe,EACnB,IAAIF,EAAU0C,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDpB,EAAYlB,GAA0BsB,EAAO,UAAWH,CAAO,EAiB/DlC,EAAaqC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIiB,EACJ,GAAK,EAAG,gBAAgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..474affa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var at="__@@##$$@@__struct_buffer__@@$$##@@__",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[at]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Ot,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",H(Ot,", "),t))},description:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:K(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,H(Et,", "),t))})};function Vt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,Nt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],kt=Y(_t);function At(t,e,n){var s;if(!et(n))throw new TypeError(u("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!kt(s.format)))throw new TypeError(u("null4S","format",H(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,_(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Bt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,at,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,wt(a)&&Jt(i.fields,s)),a.byteOffset=r,wt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;qmLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjDT,GAAUH,EAAIQ,WAEf,OAAOH,CACP,CACF,CDdUQ,CAAgBb,GET1B,SAAwBA,GACvB,OAQA,WACC,IAAII,EAAOG,KAAM5B,IACjB,OAAOmC,EAAYV,EAAKO,OAAQP,EAAKI,WAAWR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H,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/BxB,EAAMiB,GADN+H,EAAIhC,EAAQxF,IAEZvB,EAAM6E,GAAQkE,GACTA,EAAEpB,WACDoB,EAAEnB,SACNyF,EAAsBD,EAAGrE,EAAE7E,KAAMnE,EAAKC,GAEtCsN,EAAqBF,EAAGrE,EAAE7E,KAAMnE,GAEtBgJ,EAAEnB,SACb2F,EAAmCH,EAAGrE,EAAE7E,KAAMnE,EAAKC,GAEnDkN,EAAkCE,EAAGrE,EAAE7E,KAAMnE,GAE9CuB,EAAKyH,EAAE7E,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZakM,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..51f1b16 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From daf1dbf54093fbedff1c1cddaf302ed491810491 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:40:21 +0000 Subject: [PATCH 70/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 2461270d76ed317c41c5ca016f82d6973995b7df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:55:09 +0000 Subject: [PATCH 71/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 474affa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import X,{factory as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var at="__@@##$$@@__struct_buffer__@@$$##@@__",ot={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var lt={complex128:"float64",complex64:"float32",complex32:"float16"};function ft(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[at]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return X(Ot,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",H(Ot,", "),t))},description:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:xt,writable:xt,default:K(null),castingMode:(Et=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return X(Et,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,H(Et,", "),t))})};function Vt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ut(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(st(i.type.layout,s,Nt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var _t=["none","linear","layout"],kt=Y(_t);function At(t,e,n){var s;if(!et(n))throw new TypeError(u("null2V",n));if(s={format:"none"},nt(n,"format")&&(s.format=n.format,!kt(s.format)))throw new TypeError(u("null4S","format",H(_t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,_(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Bt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,at,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,wt(a)&&Jt(i.fields,s)),a.byteOffset=r,wt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;qmLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAA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,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 51f1b16..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8578b94c9f9b60accc8e427b5349cf881ad2ec53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:55:27 +0000 Subject: [PATCH 72/84] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8637 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4a268c3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-09T03:31:18.015Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,YACP,IAAO,WACR,EACA,OAAU,CACT,IAAO,eACP,IAAO,cACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,QAAW,CACV,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,UAAa,CACZ,IAAO,aACP,IAAO,YACR,EACA,WAAc,CACb,IAAO,aACP,IAAO,YACR,EACA,KAAQ,CACP,IAAO,WACP,IAAO,UACR,CACD,EAKAD,GAAO,QAAUC,KCxFjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAwBA,IAAIC,GAAmB,QAAS,iCAAkC,EAC9DC,GAAiB,IAarB,SAASC,GAAWC,EAAKC,EAAS,CACjC,OAAOC,EAQP,SAASA,GAAS,CACjB,IAAIC,EAAO,KAAML,EAAe,EAChC,OAAOK,EAAMF,CAAO,EAAGD,EAAI,WAAYH,EAAiB,CACzD,CACD,CAKAD,GAAO,QAAUG,KCxDjB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IQ,EACJ,GAAK,CAACrC,GAAkB6B,CAAI,EAC3B,MAAM,IAAI,UAAWjC,EAAQ,6EAA8EiC,CAAI,CAAE,EAElH,OAAAQ,EAAMR,EAAKhC,EAAe,EACnB,IAAIF,EAAU0C,EAAI,OAAQA,EAAI,WAAYA,EAAI,UAAW,CACjE,CAAC,EAGDpB,EAAYlB,GAA0BsB,EAAO,UAAWH,CAAO,EAiB/DlC,EAAaqC,EAAO,UAAW,WAAY,UAAoB,CAC9D,IAAIiB,EACJ,GAAK,EAAG,gBAAgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..77a60c4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.1-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.3-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import{isPrimitive as B}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import rt,{factory as it}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var pt="__@@##$$@@__struct_buffer__@@$$##@@__",ct={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var gt={complex128:"float64",complex64:"float32",complex32:"float16"};function ht(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[pt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return rt(Ut,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",tt(Ut,", "),t))},description:function(t,e){return nt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return st(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ft,writable:Ft,default:et(null),castingMode:(It=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return rt(It,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,tt(It,", "),t))})};function kt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function _t(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(dt(i.type.layout,s,Rt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var $t=["none","linear","layout"],zt=it($t);function qt(t,e,n){var s;if(!lt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},ft(n,"format")&&(s.format=n.format,!zt(s.format)))throw new TypeError(u("null4S","format",tt($t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,$(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Ct(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,pt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Vt(a)&&Bt(i.fields,s)),a.byteOffset=r,Vt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;w1MAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,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iBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..61fbbb0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 94565da9303889b5497de113daed8eb9c624af7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:44:50 +0000 Subject: [PATCH 73/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 251e2e060fb634f226a8f97f7c88fcc005431ad5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:55:40 +0000 Subject: [PATCH 74/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 77a60c4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@v0.2.2-esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@v0.3.1-esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@v0.2.3-esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as P}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as k}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import{isPrimitive as B}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import X from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as nt}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as st}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import rt,{factory as it}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import ut from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var pt="__@@##$$@@__struct_buffer__@@$$##@@__",ct={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var gt={complex128:"float64",complex64:"float32",complex32:"float16"};function ht(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[pt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return rt(Ut,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",tt(Ut,", "),t))},description:function(t,e){return nt(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return st(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Ft,writable:Ft,default:et(null),castingMode:(It=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return rt(It,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,tt(It,", "),t))})};function kt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function _t(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(dt(i.type.layout,s,Rt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var $t=["none","linear","layout"],zt=it($t);function qt(t,e,n){var s;if(!lt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},ft(n,"format")&&(s.format=n.format,!zt(s.format)))throw new TypeError(u("null4S","format",tt($t,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,$(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Ct(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,pt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Vt(a)&&Bt(i.fields,s)),a.byteOffset=r,Vt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;w1MAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjDT,GA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AASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 61fbbb0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1e66fbfabc8c388c9b314400532618f1ec98b537 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:56:11 +0000 Subject: [PATCH 75/84] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2df24ce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-17T03:35:43.353Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO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,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d12227a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{factory as at}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var dt="__@@##$$@@__struct_buffer__@@$$##@@__",mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ut={complex128:"float64",complex64:"float32",complex32:"float16"};function pt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[dt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Lt,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",et(Lt,", "),t))},description:function(t,e){return X(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Y(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:St,writable:St,default:W(null),castingMode:(Vt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Vt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,et(Vt,", "),t))})};function Jt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function kt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(ot(i.type.layout,s,At(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Rt=at(Bt);function Dt(t,e,n){var s;if(!rt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},it(n,"format")&&(s.format=n.format,!Rt(s.format)))throw new TypeError(u("null4S","format",Q(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,A(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function $t(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,dt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Tt(a)&&_t(i.fields,s)),a.byteOffset=r,Tt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getNumber","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;8kMAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA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AEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQlM,gBAAgB4I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAI1F,EACA0H,EACA1F,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAIsK,GADJ5E,EAAIhC,EAAQzF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPzM,EAAK0H,EAAE7E,MAASb,EAEjB,OAAOhC,CACR,CPscS0M,CAAaxM,KAAMwK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..94fd883 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 428a4f67ff1b9b43e854a11fcb1707a6dee674d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 03:43:48 +0000 Subject: [PATCH 76/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 533b7fa1bc147ab12263a3d86d4a7e4b105d4b40 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 04:04:53 +0000 Subject: [PATCH 77/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d12227a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import{isPrimitive as N}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.3-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import K from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import Q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import W from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import{isPrimitive as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{factory as at}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var dt="__@@##$$@@__struct_buffer__@@$$##@@__",mt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ut={complex128:"float64",complex64:"float32",complex32:"float16"};function pt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[dt]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return tt(Lt,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",et(Lt,", "),t))},description:function(t,e){return X(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Y(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:St,writable:St,default:W(null),castingMode:(Vt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return tt(Vt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,et(Vt,", "),t))})};function Jt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function kt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(ot(i.type.layout,s,At(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Rt=at(Bt);function Dt(t,e,n){var s;if(!rt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},it(n,"format")&&(s.format=n.format,!Rt(s.format)))throw new TypeError(u("null4S","format",Q(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,A(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function $t(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,dt,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Tt(a)&&_t(i.fields,s)),a.byteOffset=r,Tt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getNumber","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;8kMAuBA,IAAIA,GAAiB,wCCDjBC,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EACA0H,EACAzH,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/BxB,EAAMiB,GADNgI,EAAIhC,EAAQzF,IAEZvB,EAAM8E,GAAQkE,GACTA,EAAEpB,WACDoB,EAAEnB,SACNyF,EAAsBD,EAAGrE,EAAE7E,KAAMpE,EAAKC,GAEtCuN,EAAqBF,EAAGrE,EAAE7E,KAAMpE,GAEtBiJ,EAAEnB,SACb2F,EAAmCH,EAAGrE,EAAE7E,KAAMpE,EAAKC,GAEnDmN,EAAkCE,EAAGrE,EAAE7E,KAAMpE,GAE9CuB,EAAK0H,EAAE7E,MAAS,CAAEpE,EAAKC,GAExB,OAAOsB,CACR,CNgZamM,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQlM,gBAAgB4I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUrL,OAAS,EAChBqL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQlM,gBAAgB4I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAI1F,EACA0H,EACA1F,EACA/B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIyF,EAAO9F,OAAQK,IAE/B+B,EAAIsK,GADJ5E,EAAIhC,EAAQzF,IACE4C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPzM,EAAK0H,EAAE7E,MAASb,EAEjB,OAAOhC,CACR,CPscS0M,CAAaxM,KAAMwK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 94fd883..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4d9c0af514974a585dcbc7fdb6a4bdd66640d6a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 04:05:15 +0000 Subject: [PATCH 78/84] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8655 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2cb2084..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-20T03:34:39.433Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5dac6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 10622f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,MAAS,CACR,IAAO,cACP,IAAO,aACR,EACA,MAAS,CACR,IAAO,WACP,IAAO,UACR,EACA,OAAU,CACT,IAAO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BA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..443177c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W,{factory as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var it="__@@##$$@@__struct_buffer__@@$$##@@__",at={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ot={complex128:"float64",complex64:"float32",complex32:"float16"};function lt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[it]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(xt,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",G(xt,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:wt,writable:wt,default:H(null),castingMode:(Ot=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return W(Ot,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,G(Ot,", "),t))})};function Lt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ft(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(nt(i.type.layout,s,Jt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var kt=["none","linear","layout"],Mt=X(kt);function _t(t,e,n){var s;if(!tt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},et(n,"format")&&(s.format=n.format,!Mt(s.format)))throw new TypeError(u("null4S","format",G(kt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,k(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function At(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,it,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,jt(a)&&It(i.fields,s)),a.byteOffset=r,jt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;qgLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,K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EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,EAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..45a5c9d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 516aa8e7afe56aadc8d96bfdf624aae26dab4044 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 30 Jun 2026 03:45:49 +0000 Subject: [PATCH 79/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From c2e3a9a82b04ab1366cc0a0048e451330fa0d00f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 30 Jun 2026 03:56:56 +0000 Subject: [PATCH 80/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 443177c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W,{factory as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var it="__@@##$$@@__struct_buffer__@@$$##@@__",at={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ot={complex128:"float64",complex64:"float32",complex32:"float16"};function lt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[it]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(xt,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",G(xt,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:wt,writable:wt,default:H(null),castingMode:(Ot=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return W(Ot,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,G(Ot,", "),t))})};function Lt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Ft(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(nt(i.type.layout,s,Jt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var kt=["none","linear","layout"],Mt=X(kt);function _t(t,e,n){var s;if(!tt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},et(n,"format")&&(s.format=n.format,!Mt(s.format)))throw new TypeError(u("null4S","format",G(kt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,k(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function At(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,it,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,jt(a)&&It(i.fields,s)),a.byteOffset=r,jt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;qgLAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,KAAM,IAAIT,EAAIU,KAAMN,EAAKO,OAAQR,EAAQH,EAAIY,aACjDT,GAAUH,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EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 45a5c9d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5a7dcefeab24b79dca974dc3431d2239b5497168 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 30 Jun 2026 03:57:36 +0000 Subject: [PATCH 81/84] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8655 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e9db92c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-30T03:39:34.474Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 764d656..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){try{return i||e((i={exports:{}}).exports,i),i.exports}catch(r){throw i=0,r}}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ffa4c34..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAoB,CACvB,KAAQ,CACP,IAAO,UACP,IAAO,SACR,EACA,MAAS,CACR,I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AO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abfa2fd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W,{factory as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var ft="__@@##$$@@__struct_buffer__@@$$##@@__",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ft]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(St,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",Y(St,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:H(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Z(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Y(Lt,", "),t))})};function It(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Nt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(it(i.type.layout,s,_t(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Pt=X(Bt);function Rt(t,e,n){var s;if(!nt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},st(n,"format")&&(s.format=n.format,!Pt(s.format)))throw new TypeError(u("null4S","format",Y(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,rt(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Dt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ft,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Et(a)&&Mt(i.fields,s)),a.byteOffset=r,Et(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;q2LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAA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M,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2b80e8f --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests From 53978a765004f8e7cbdfffe53f121741f8a91709 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:14:31 +0000 Subject: [PATCH 82/84] Transform error messages --- lib/field_index.js | 2 +- lib/field_names.js | 2 +- lib/format_layout.js | 2 +- lib/format_linear.js | 2 +- lib/getter.js | 2 +- lib/is_valid_boolean.js | 2 +- lib/is_valid_nonempty_string.js | 2 +- lib/is_valid_one_of.js | 2 +- lib/is_valid_positive_integer.js | 2 +- lib/is_valid_string.js | 2 +- lib/is_valid_type.js | 2 +- lib/main.js | 8 ++++---- lib/normalize_field.js | 2 +- lib/normalize_field_list.js | 2 +- lib/normalize_union.js | 2 +- lib/set_bigint.js | 2 +- lib/set_boolean.js | 2 +- lib/set_complex.js | 2 +- lib/set_number.js | 2 +- lib/set_struct.js | 2 +- lib/set_struct_array.js | 2 +- lib/set_typedarray.js | 2 +- lib/setter.js | 2 +- lib/to_string.js | 6 +++--- package.json | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/field_index.js b/lib/field_index.js index 7d163ef..ae050da 100644 --- a/lib/field_index.js +++ b/lib/field_index.js @@ -22,7 +22,7 @@ var indexOf = require( '@stdlib/array-base-index-of' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/field_names.js b/lib/field_names.js index c70bede..b83b5f3 100644 --- a/lib/field_names.js +++ b/lib/field_names.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); diff --git a/lib/format_layout.js b/lib/format_layout.js index e253ba4..e11ce83 100644 --- a/lib/format_layout.js +++ b/lib/format_layout.js @@ -21,7 +21,7 @@ // MODULES // var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // diff --git a/lib/format_linear.js b/lib/format_linear.js index 9cd73a4..f8c9095 100644 --- a/lib/format_linear.js +++ b/lib/format_linear.js @@ -21,7 +21,7 @@ // MODULES // var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/getter.js b/lib/getter.js index 581a5bd..efd1f9c 100644 --- a/lib/getter.js +++ b/lib/getter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var getNumber = require( './get_number.js' ); var getBoolean = require( './get_boolean.js' ); diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js index 120b1f0..d375c2c 100644 --- a/lib/is_valid_boolean.js +++ b/lib/is_valid_boolean.js @@ -21,7 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js index 03dae5e..65da8da 100644 --- a/lib/is_valid_nonempty_string.js +++ b/lib/is_valid_nonempty_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js index 3757784..b5fa15e 100644 --- a/lib/is_valid_one_of.js +++ b/lib/is_valid_one_of.js @@ -22,7 +22,7 @@ var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js index 50d22af..013600e 100644 --- a/lib/is_valid_positive_integer.js +++ b/lib/is_valid_positive_integer.js @@ -21,7 +21,7 @@ // MODULES // var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js index 642d2e2..89e4a03 100644 --- a/lib/is_valid_string.js +++ b/lib/is_valid_string.js @@ -21,7 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js index 10f7b24..487a32e 100644 --- a/lib/is_valid_type.js +++ b/lib/is_valid_type.js @@ -23,7 +23,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DTYPES = require( './dtypes.js' ); diff --git a/lib/main.js b/lib/main.js index 80fa7af..bf3bfa8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var min = require( '@stdlib/math-base-special-fast-min' ); var filled = require( '@stdlib/array-base-filled' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var CTOR_NAME = require( './ctor_name.js' ); var createPrototypeAccessors = require( './create_prototype_accessors.js' ); @@ -116,7 +116,7 @@ function factory( fields ) { var tmp; var o; if ( !isCollection( fields ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) ); + throw new TypeError( format( 'null2O', fields ) ); } // Normalize the list of field objects: tmp = normalize( fields ); @@ -191,7 +191,7 @@ function factory( fields ) { view = new DataView( arg, 0, BYTE_LENGTH ); } else { if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( nargs === 2 ) { view = new DataView( arg, byteOffset, BYTE_LENGTH ); @@ -209,7 +209,7 @@ function factory( fields ) { view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); if ( nargs > 0 ) { if ( !isObject( arg ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null3L', arg ) ); } obj = arg; } diff --git a/lib/normalize_field.js b/lib/normalize_field.js index c38acba..633f85f 100644 --- a/lib/normalize_field.js +++ b/lib/normalize_field.js @@ -24,7 +24,7 @@ var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-lik var hasProp = require( '@stdlib/assert-has-property' ); var join = require( '@stdlib/array-base-join' ); var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var hasProperties = require( './has_properties.js' ); var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); var isValidString = require( './is_valid_string.js' ); diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js index e0909bc..8f55deb 100644 --- a/lib/normalize_field_list.js +++ b/lib/normalize_field_list.js @@ -21,7 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var isUnionType = require( './is_union_type.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/normalize_union.js b/lib/normalize_union.js index c4ecd7e..74f77ab 100644 --- a/lib/normalize_union.js +++ b/lib/normalize_union.js @@ -22,7 +22,7 @@ var isObject = require( '@stdlib/assert-is-object' ); var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isUnionType = require( './is_union_type.js' ); var FIELD_PROPERTIES = require( './field_properties.js' ); var normalizeField = require( './normalize_field.js' ); diff --git a/lib/set_bigint.js b/lib/set_bigint.js index 1fd462b..4154da0 100644 --- a/lib/set_bigint.js +++ b/lib/set_bigint.js @@ -34,7 +34,7 @@ var complexDType = require( '@stdlib/complex-dtype' ); var BigInt = require( '@stdlib/bigint-ctor' ); var Number = require( '@stdlib/number-ctor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2bigint = require( './boolean2bigint.js' ); var defaults = require( './defaults.json' ); diff --git a/lib/set_boolean.js b/lib/set_boolean.js index 00169a8..02d1bda 100644 --- a/lib/set_boolean.js +++ b/lib/set_boolean.js @@ -30,7 +30,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var boolean2number = require( './boolean2number.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/set_complex.js b/lib/set_complex.js index 7cd139a..5cd4315 100644 --- a/lib/set_complex.js +++ b/lib/set_complex.js @@ -29,7 +29,7 @@ var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_number.js b/lib/set_number.js index 99f8b27..b7e5075 100644 --- a/lib/set_number.js +++ b/lib/set_number.js @@ -34,7 +34,7 @@ var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-c var minDataType = require( '@stdlib/array-min-dtype' ); var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var boolean2number = require( './boolean2number.js' ); var bigint2number = require( './bigint2number.js' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_struct.js b/lib/set_struct.js index 7e44c9a..63a0a76 100644 --- a/lib/set_struct.js +++ b/lib/set_struct.js @@ -24,7 +24,7 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js index f7b5c0e..bbdcac3 100644 --- a/lib/set_struct_array.js +++ b/lib/set_struct_array.js @@ -25,7 +25,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var Uint8Array = require( '@stdlib/array-uint8' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js index 51e60ca..a56d413 100644 --- a/lib/set_typedarray.js +++ b/lib/set_typedarray.js @@ -34,7 +34,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var gcopy = require( '@stdlib/blas-base-gcopy' ); var gfill = require( '@stdlib/blas-ext-base-gfill' ); var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var PRIVATE_BUFFER = require( './private_buffer.js' ); var isStructInstance = require( './is_struct_instance.js' ); var number2boolean = require( './number2boolean.js' ); diff --git a/lib/setter.js b/lib/setter.js index c53252f..8365f76 100644 --- a/lib/setter.js +++ b/lib/setter.js @@ -20,7 +20,7 @@ // MODULES // -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DATA_VIEW_METHODS = require( './data_view_methods.js' ); var setNumber = require( './set_number.js' ); var setComplex = require( './set_complex.js' ); diff --git a/lib/to_string.js b/lib/to_string.js index c4e7fc6..c761c94 100644 --- a/lib/to_string.js +++ b/lib/to_string.js @@ -24,7 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ).factory; var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var linearFormat = require( './format_linear.js' ); var layoutFormat = require( './format_layout.js' ); @@ -56,7 +56,7 @@ var isFormat = contains( FORMATS ); function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare var opts; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } opts = { 'format': 'none' @@ -64,7 +64,7 @@ function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no- if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) ); + throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); } } if ( opts.format === 'linear' ) { diff --git a/package.json b/package.json index 505fce5..d8f8b2a 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", "@stdlib/strided-base-reinterpret-complex": "^0.1.3", "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-constant-function": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 3e9b99f5c8d6c8a71608b0eb37f8f20c5f95b449 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:24:46 +0000 Subject: [PATCH 83/84] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abfa2fd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import W,{factory as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import Y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import Z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var ft="__@@##$$@@__struct_buffer__@@$$##@@__",dt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var mt={complex128:"float64",complex64:"float32",complex32:"float16"};function ut(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ft]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return W(St,t)||n(t)?null:new TypeError(u('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",Y(St,", "),t))},description:function(t,e){return K(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Tt,writable:Tt,default:H(null),castingMode:(Lt=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return Z(Lt,t)?null:new TypeError(u('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,Y(Lt,", "),t))})};function It(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function Nt(t){var e,n,s,r,i,l,f;if(0===(e=t.fields).length)return null;for(s=[],f=0;f0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(it(i.type.layout,s,_t(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Bt=["none","linear","layout"],Pt=X(Bt);function Rt(t,e,n){var s;if(!nt(n))throw new TypeError(u("null2V",n));if(s={format:"none"},st(n,"format")&&(s.format=n.format,!Pt(s.format)))throw new TypeError(u("null4S","format",Y(Bt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,rt(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function Dt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ft,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Et(a)&&Mt(i.fields,s)),a.byteOffset=r,Et(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;q2LAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF,IAAO,WACPC,IAAO,YAERE,MAAS,CACRH,IAAO,WACPC,IAAO,YAERG,MAAS,CACRJ,IAAO,cACPC,IAAO,eAERI,MAAS,CACRL,IAAO,WACPC,IAAO,YAERK,OAAU,CACTN,IAAO,YACPC,IAAO,aAERM,OAAU,CACTP,IAAO,YACPC,IAAO,aAERO,OAAU,CACTR,IAAO,eACPC,IAAO,gBAERQ,QAAW,CACVT,IAAO,aACPC,IAAO,cAERS,QAAW,CACVV,IAAO,aACPC,IAAO,cAERU,QAAW,CACVX,IAAO,aACPC,IAAO,cAERW,UAAa,CACZZ,IAAO,aACPC,IAAO,cAERY,UAAa,CACZb,IAAO,aACPC,IAAO,cAERa,WAAc,CACbd,IAAO,aACPC,IAAO,cAERc,KAAQ,CACPf,IAAO,WACPC,IAAO,aClDT,IAAIe,GAAgB,CACnBF,WAAc,UACdD,UAAa,UACbD,UAAa,WCSd,SAASK,GAAQC,GAChB,GAAKA,EAAIC,OACR,OAAKD,EAAIE,aCTX,SAAyBF,GACxB,OAQA,WACC,IAAIG,EACAC,EACAC,EACAC,EAKJ,IAFAH,GADAC,EAAOG,KAAM5B,KACC6B,WAAaR,EAAIQ,WAC/BH,EAAM,GACAC,EAAI,EAAGA,EAAIN,EAAIC,OAAQK,IAC5BD,EAAII,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AYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2b80e8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3f1c34f6a0492ae00c9080bb497f2b3b9bccef88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:25:31 +0000 Subject: [PATCH 84/84] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 103 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 78 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 140 - examples/nested_struct.js | 89 - examples/union.js | 85 - examples/union_with_complex.js | 80 - examples/union_with_struct.js | 104 - index.mjs | 4 + index.mjs.map | 1 + lib/alignments.js | 48 - lib/bigint2boolean.js | 42 - lib/bigint2number.js | 42 - lib/boolean2bigint.js | 42 - lib/boolean2number.js | 37 - lib/byte_length.js | 51 - lib/byte_offsets.js | 121 - lib/casting_modes.js | 34 - lib/complex2boolean.js | 42 - lib/complex2number.js | 37 - lib/create_prototype_accessors.js | 74 - lib/ctor_name.js | 28 - lib/data_view_methods.js | 89 - lib/defaults.json | 6 - lib/dtypes.js | 50 - lib/field_index.js | 55 - lib/field_names.js | 73 - lib/field_properties.js | 37 - lib/flatten_fields.js | 58 - lib/format_layout.js | 127 - lib/format_linear.js | 181 - lib/get_bigint.js | 57 - lib/get_boolean.js | 58 - lib/get_complex.js | 69 - lib/get_number.js | 57 - lib/get_struct.js | 55 - lib/get_struct_array.js | 66 - lib/get_typedarray.js | 56 - lib/getter.js | 87 - lib/has_properties.js | 49 - lib/index.js | 75 - lib/init_field_object.js | 47 - lib/is_struct_instance.js | 48 - lib/is_union_type.js | 42 - lib/is_valid_boolean.js | 47 - lib/is_valid_nonempty_string.js | 47 - lib/is_valid_one_of.js | 59 - lib/is_valid_positive_integer.js | 47 - lib/is_valid_string.js | 47 - lib/is_valid_type.js | 49 - lib/main.js | 523 -- lib/normalize_field.js | 105 - lib/normalize_field_list.js | 75 - lib/normalize_union.js | 92 - lib/number2boolean.js | 42 - lib/partitions.js | 65 - lib/private_buffer.js | 29 - lib/resolve_alignment.js | 48 - lib/set_bigint.js | 99 - lib/set_boolean.js | 93 - lib/set_complex.js | 96 - lib/set_number.js | 103 - lib/set_struct.js | 83 - lib/set_struct_array.js | 103 - lib/set_typedarray.js | 152 - lib/setter.js | 87 - lib/to_json.js | 65 - lib/to_string.js | 83 - package.json | 110 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 100 files changed, 4863 insertions(+), 8656 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js delete mode 100644 examples/nested_struct.js delete mode 100644 examples/union.js delete mode 100644 examples/union_with_complex.js delete mode 100644 examples/union_with_struct.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/alignments.js delete mode 100644 lib/bigint2boolean.js delete mode 100644 lib/bigint2number.js delete mode 100644 lib/boolean2bigint.js delete mode 100644 lib/boolean2number.js delete mode 100644 lib/byte_length.js delete mode 100644 lib/byte_offsets.js delete mode 100644 lib/casting_modes.js delete mode 100644 lib/complex2boolean.js delete mode 100644 lib/complex2number.js delete mode 100644 lib/create_prototype_accessors.js delete mode 100644 lib/ctor_name.js delete mode 100644 lib/data_view_methods.js delete mode 100644 lib/defaults.json delete mode 100644 lib/dtypes.js delete mode 100644 lib/field_index.js delete mode 100644 lib/field_names.js delete mode 100644 lib/field_properties.js delete mode 100644 lib/flatten_fields.js delete mode 100644 lib/format_layout.js delete mode 100644 lib/format_linear.js delete mode 100644 lib/get_bigint.js delete mode 100644 lib/get_boolean.js delete mode 100644 lib/get_complex.js delete mode 100644 lib/get_number.js delete mode 100644 lib/get_struct.js delete mode 100644 lib/get_struct_array.js delete mode 100644 lib/get_typedarray.js delete mode 100644 lib/getter.js delete mode 100644 lib/has_properties.js delete mode 100644 lib/index.js delete mode 100644 lib/init_field_object.js delete mode 100644 lib/is_struct_instance.js delete mode 100644 lib/is_union_type.js delete mode 100644 lib/is_valid_boolean.js delete mode 100644 lib/is_valid_nonempty_string.js delete mode 100644 lib/is_valid_one_of.js delete mode 100644 lib/is_valid_positive_integer.js delete mode 100644 lib/is_valid_string.js delete mode 100644 lib/is_valid_type.js delete mode 100644 lib/main.js delete mode 100644 lib/normalize_field.js delete mode 100644 lib/normalize_field_list.js delete mode 100644 lib/normalize_union.js delete mode 100644 lib/number2boolean.js delete mode 100644 lib/partitions.js delete mode 100644 lib/private_buffer.js delete mode 100644 lib/resolve_alignment.js delete mode 100644 lib/set_bigint.js delete mode 100644 lib/set_boolean.js delete mode 100644 lib/set_complex.js delete mode 100644 lib/set_number.js delete mode 100644 lib/set_struct.js delete mode 100644 lib/set_struct_array.js delete mode 100644 lib/set_typedarray.js delete mode 100644 lib/setter.js delete mode 100644 lib/to_json.js delete mode 100644 lib/to_string.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d9d9506..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-19T03:12:00.689Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index de7f5e6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8a284d6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1a6bc38..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -304,7 +295,7 @@ console.log( 'Description: %s', desc ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b7ae520..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var struct = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ - { - 'name': 'foo', - 'type': 'float64' - } - ], - [ - { - 'name': 'bar', - 'type': 'float32' - } - ], - [ - { - 'name': 'beep', - 'type': 'int32' - } - ], - [ - { - 'name': 'boop', - 'type': 'uint32' - } - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = struct( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// FIXME: add benchmarks diff --git a/branches.md b/branches.md deleted file mode 100644 index 724c562..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct" -%% click B href "https://github.com/stdlib-js/dstructs-struct/tree/main" -%% click C href "https://github.com/stdlib-js/dstructs-struct/tree/production" -%% click D href "https://github.com/stdlib-js/dstructs-struct/tree/esm" -%% click E href "https://github.com/stdlib-js/dstructs-struct/tree/deno" -%% click F href "https://github.com/stdlib-js/dstructs-struct/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct -[production-url]: https://github.com/stdlib-js/dstructs-struct/tree/production -[deno-url]: https://github.com/stdlib-js/dstructs-struct/tree/deno -[deno-readme]: https://github.com/stdlib-js/dstructs-struct/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/dstructs-struct/tree/umd -[umd-readme]: https://github.com/stdlib-js/dstructs-struct/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/dstructs-struct/tree/esm -[esm-readme]: https://github.com/stdlib-js/dstructs-struct/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 764d656..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var u=function(e,i){return function(){try{return i||e((i={exports:{}}).exports,i),i.exports}catch(r){throw i=0,r}}};var m=u(function(ou,ve){"use strict";var Et="__@@##$$@@__struct_buffer__@@$$##@@__";ve.exports=Et});var ce=u(function(fu,le){"use strict";var wt="Struct";le.exports=wt});var Y=u(function(vu,ge){"use strict";var Tt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};ge.exports=Tt});var me=u(function(lu,pe){"use strict";var xt=require("@stdlib/assert-is-little-endian"),Ot=m();function bt(e,i){return r;function r(){var t=this[Ot];return t[i](e.byteOffset,xt)}}pe.exports=bt});var qe=u(function(cu,ye){"use strict";var It=require("@stdlib/assert-is-little-endian"),St=require("@stdlib/boolean-ctor"),At=m();function Ft(e,i){return r;function r(){var t=this[At];return St(t[i](e.byteOffset,It))}}ye.exports=Ft});var Ee=u(function(gu,de){"use strict";var he=require("@stdlib/assert-is-little-endian"),Nt=require("@stdlib/complex-cmplx"),Vt=m(),Lt={complex128:"float64",complex64:"float32",complex32:"float16"};function Pt(e,i){return r;function r(){var t=this[Vt],s=t[i](e.byteOffset,he),n=t[i](e.byteOffset+e.byteLength/2,he);return Nt(s,n,Lt[e.type])}}de.exports=Pt});var Te=u(function(pu,we){"use strict";var Rt=require("@stdlib/assert-is-little-endian"),_t=m();function Bt(e,i){return r;function r(){var t=this[_t];return t[i](e.byteOffset,Rt)}}we.exports=Bt});var Oe=u(function(mu,xe){"use strict";var Dt=m();function Ut(e){return i;function i(){var r=this[Dt];return new e.type(r.buffer,r.byteOffset+e.byteOffset,e.byteLength)}}xe.exports=Ut});var Ie=u(function(yu,be){"use strict";var Ct=require("@stdlib/array-typed"),Mt=m();function kt(e){return i;function i(){var r=this[Mt];return Ct(r.buffer,r.byteOffset+e.byteOffset,e.length,e.type)}}be.exports=kt});var Ae=u(function(qu,Se){"use strict";var Jt=m();function zt(e){return i;function i(){var r,t,s,n;for(t=this[Jt],r=t.byteOffset+e.byteOffset,s=[],n=0;n0?null:new TypeError(ua("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",i,e))}yr.exports=oa});var dr=u(function(ku,hr){"use strict";var fa=require("@stdlib/assert-is-string").isPrimitive,va=require("@stdlib/string-format");function la(e,i){return fa(e)?null:new TypeError(va("invalid argument. `%s` field must be a string. Value: `%s`.",i,e))}hr.exports=la});var wr=u(function(Ju,Er){"use strict";var ca=require("@stdlib/assert-is-positive-integer").isPrimitive,ga=require("@stdlib/string-format");function pa(e,i){return ca(e)?null:new TypeError(ga("invalid argument. `%s` field must be a positive integer. Value: `%s`.",i,e))}Er.exports=pa});var xr=u(function(zu,Tr){"use strict";var ma=require("@stdlib/assert-is-boolean").isPrimitive,ya=require("@stdlib/string-format");function qa(e,i){return ma(e)?null:new TypeError(ya("invalid argument. `%s` field must be a boolean. Value: `%s`.",i,e))}Tr.exports=qa});var br=u(function(Gu,Or){"use strict";var ha=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64","complex64","complex128","bool"];Or.exports=ha});var Ar=u(function(Wu,Sr){"use strict";var da=require("@stdlib/assert-is-struct-constructor-like"),Ea=require("@stdlib/array-base-assert-contains"),wa=require("@stdlib/array-base-join"),Ta=require("@stdlib/string-format"),Ir=br();function xa(e){return Ea(Ir,e)||da(e)?null:new TypeError(Ta('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",wa(Ir,", "),e))}Sr.exports=xa});var Nr=u(function(Hu,Fr){"use strict";var Oa=require("@stdlib/array-base-assert-contains"),ba=require("@stdlib/array-base-join"),Ia=require("@stdlib/string-format");function Sa(e){return i;function i(r,t){return Oa(e,r)?null:new TypeError(Ia('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',t,ba(e,", "),r))}}Fr.exports=Sa});var Lr=u(function(Yu,Vr){"use strict";function Aa(){return{isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"}}Vr.exports=Aa});var Rr=u(function($u,Pr){"use strict";var Fa=require("@stdlib/ndarray-base-bytes-per-element");function Na(e){var i;return e.isStructType?i=e.type.byteLength:i=Fa(e.type),e.length&&(i*=e.length),i}Pr.exports=Na});var Br=u(function(Xu,_r){"use strict";var Va=["none","safe","mostly-safe","same-kind","unsafe"];_r.exports=Va});var Ur=u(function(Ku,Dr){"use strict";var La={int8:1,int16:2,int32:4,int64:8,uint8:1,uint16:2,uint32:4,uint64:8,float16:2,float32:4,float64:8,complex32:2,complex64:4,complex128:8,bool:1};Dr.exports=La});var te=u(function(Qu,kr){"use strict";var Pa=require("@stdlib/assert-is-struct-constructor-like"),Ra=require("@stdlib/assert-has-property"),_a=require("@stdlib/array-base-join"),Ba=require("@stdlib/utils-constant-function"),Da=require("@stdlib/string-format"),Ua=mr(),Ca=qr(),Ma=dr(),ka=wr(),Cr=xr(),Ja=Ar(),za=Nr(),Ga=Lr(),Wa=Rr(),Ha=Br(),Ya=Ur(),Mr=["name","type"],$a={name:Ca,type:Ja,description:Ma,length:ka,enumerable:Cr,writable:Cr,default:Ba(null),castingMode:za(Ha)};function Xa(e,i){var r,t,s,n,a;for(r=Ga(),a=0;ai&&(i=r);return i}Jr.exports=Ka});var Wr=u(function(ju,Gr){"use strict";var Qa=require("@stdlib/assert-is-object"),zr=require("@stdlib/assert-has-property"),ne=require("@stdlib/string-format"),Za=L(),ja=re(),es=te(),rs=ie();function ts(e){var i,r,t,s,n,a,o;if(i=e.fields,i.length===0)return null;for(t=[],o=0;o0&&(n=e[o-1],n.padding=t,ae(a)&&et(n.fields,t)),a.byteOffset=s,ae(a))for(p=0;pb&&(b=A);for(s="%"+b+"s",n="// %s",p="%s: %s %s",g=0,f=[],q=0;q0&&c.byteOffset===i[q-1].byteOffset)){for(q1?a=" (byte %u)":a="",l){for(o=" => union: %s",v=[],P=q+1;P":F=E.type,v.push(y("%s<%s>[%u]",E.name,F,T%E.alignment)),P+=1;o=y(o,v.join(", "))}else o="";v=y(a+o,T%c.alignment),c.length?w=y(n,y("%s[%u]%s",c.type,Es(T/c.alignment),v)):w=y(n,y("%s%s",c.type,v)),f.push(y(p,x,d,w)),g+=1}for(T=0;T0&&n.byteOffset===e[a-1].byteOffset)){if(n.isStructType){i.push(Ts(n.type.layout,t,Os(n.byteOffset)));continue}i.push(se("|<%s>[%u,%u]",n.type,n.byteOffset,n.byteLength))}return r=se("%s|",i.join("")),r[r.length-2]==="|"&&(r=r.substring(0,r.length-1)),r}ft.exports=bs});var gt=u(function(oo,ct){"use strict";var Is=require("@stdlib/assert-is-plain-object"),Ss=require("@stdlib/assert-has-own-property"),As=require("@stdlib/array-base-assert-contains").factory,Fs=require("@stdlib/array-base-join"),vt=require("@stdlib/string-format"),Ns=ot(),Vs=ue(),lt=["none","linear","layout"],Ls=As(lt);function Ps(e,i,r){var t;if(!Is(r))throw new TypeError(vt("invalid argument. Options argument must be an object. Value: `%s`.",r));if(t={format:"none"},Ss(r,"format")&&(t.format=r.format,!Ls(t.format)))throw new TypeError(vt('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"format",Fs(lt,", "),r.format));return t.format==="linear"?Ns(e,i):t.format==="layout"?Vs(i):""}ct.exports=Ps});var mt=u(function(fo,pt){"use strict";var Rs=require("@stdlib/assert-is-collection"),_s=require("@stdlib/assert-is-complex-like"),Bs=require("@stdlib/assert-is-function"),Ds=require("@stdlib/array-to-json"),Us=R();function Cs(e,i){var r,t,s,n;for(r={},n=0;n0){if(!zs(f))throw new TypeError(N("invalid argument. First argument must be an object. Value: `%s`.",f));b=f}if(h(this,oe,O),b!==void 0){for(x=Hs(void 0,a.length),w={},c=0;c0?l=arguments[0]:l={},tu(v,a,l)}),h(v.prototype,"toJSON",function(){if(!(this instanceof v))throw new Error("invalid invocation. `this` is not a struct instance.");return iu(this,a)}),v}ht.exports=au});var su=dt();module.exports=su; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ffa4c34..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/private_buffer.js", "../lib/ctor_name.js", "../lib/data_view_methods.js", "../lib/get_number.js", "../lib/get_boolean.js", "../lib/get_complex.js", "../lib/get_bigint.js", "../lib/get_struct.js", "../lib/get_typedarray.js", "../lib/get_struct_array.js", "../lib/getter.js", "../lib/boolean2number.js", "../lib/bigint2number.js", "../lib/defaults.json", "../lib/set_number.js", "../lib/set_complex.js", "../lib/number2boolean.js", "../lib/complex2boolean.js", "../lib/bigint2boolean.js", "../lib/set_boolean.js", "../lib/boolean2bigint.js", "../lib/set_bigint.js", "../lib/is_struct_instance.js", "../lib/set_struct.js", "../lib/complex2number.js", "../lib/set_typedarray.js", "../lib/set_struct_array.js", "../lib/setter.js", "../lib/create_prototype_accessors.js", "../lib/field_properties.js", "../lib/is_union_type.js", "../lib/has_properties.js", "../lib/is_valid_nonempty_string.js", "../lib/is_valid_string.js", "../lib/is_valid_positive_integer.js", "../lib/is_valid_boolean.js", "../lib/dtypes.js", "../lib/is_valid_type.js", "../lib/is_valid_one_of.js", "../lib/init_field_object.js", "../lib/byte_length.js", "../lib/casting_modes.js", "../lib/alignments.js", "../lib/normalize_field.js", "../lib/resolve_alignment.js", "../lib/normalize_union.js", "../lib/normalize_field_list.js", "../lib/field_names.js", "../lib/field_index.js", "../lib/byte_offsets.js", "../lib/partitions.js", "../lib/flatten_fields.js", "../lib/format_linear.js", "../lib/format_layout.js", "../lib/to_string.js", "../lib/to_json.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Define a property name which is unlikely to be used in end user code:\nvar PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__';\n\n\n// EXPORTS //\n\nmodule.exports = PRIVATE_BUFFER;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nmodule.exports = CTOR_NAME;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DATA_VIEW_METHODS = {\n\t'int8': {\n\t\t'get': 'getInt8',\n\t\t'set': 'setInt8'\n\t},\n\t'int16': {\n\t\t'get': 'getInt16',\n\t\t'set': 'setInt16'\n\t},\n\t'int32': {\n\t\t'get': 'getInt32',\n\t\t'set': 'setInt32'\n\t},\n\t'int64': {\n\t\t'get': 'getBigInt64',\n\t\t'set': 'setBigInt64'\n\t},\n\t'uint8': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t},\n\t'uint16': {\n\t\t'get': 'getUint16',\n\t\t'set': 'setUint16'\n\t},\n\t'uint32': {\n\t\t'get': 'getUint32',\n\t\t'set': 'setUint32'\n\t},\n\t'uint64': {\n\t\t'get': 'getBigUint64',\n\t\t'set': 'setBigUint64'\n\t},\n\t'float16': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'float32': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'float64': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'complex32': {\n\t\t'get': 'getFloat16',\n\t\t'set': 'setFloat16'\n\t},\n\t'complex64': {\n\t\t'get': 'getFloat32',\n\t\t'set': 'setFloat32'\n\t},\n\t'complex128': {\n\t\t'get': 'getFloat64',\n\t\t'set': 'setFloat64'\n\t},\n\t'bool': {\n\t\t'get': 'getUint8',\n\t\t'set': 'setUint8'\n\t}\n};\n\n\n// EXPORTS //\n\nmodule.exports = DATA_VIEW_METHODS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getNumber( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a number value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {number} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar complex = require( '@stdlib/complex-cmplx' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// VARIABLES //\n\nvar CMPLX_TO_REAL = {\n\t'complex128': 'float64',\n\t'complex64': 'float32',\n\t'complex32': 'float16'\n};\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getComplex( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a complex number from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Complex} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\tvar re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t\tvar im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN );\n\t\treturn complex( re, im, CMPLX_TO_REAL[ obj.type ] );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar typedarray = require( '@stdlib/array-typed' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStructArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a list of `struct` views of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Array} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar getNumber = require( './get_number.js' );\nvar getBoolean = require( './get_boolean.js' );\nvar getComplex = require( './get_complex.js' );\nvar getBigInt = require( './get_bigint.js' );\nvar getStruct = require( './get_struct.js' );\nvar getTypedArray = require( './get_typedarray.js' );\nvar getStructArray = require( './get_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for resolving field data\n*/\nfunction getter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStructArray( obj );\n\t\t}\n\t\treturn getTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'bool':\n\t\treturn getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn getStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Number = require( '@stdlib/number-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2number;\n", "{\n \"dtypes\": {\n \"real\": \"float64\",\n \"complex\": \"complex128\"\n }\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length\nvar isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setNumber;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar format = require( '@stdlib/string-format' );\nvar boolean2number = require( './boolean2number.js' );\nvar bigint2number = require( './bigint2number.js' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setComplex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = number2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = bigint2boolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2number = require( './boolean2number.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar bigint2boolean = require( './bigint2boolean.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar BigInt = require( '@stdlib/bigint-ctor' );\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = boolean2bigint;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive;\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar minDataType = require( '@stdlib/array-min-dtype' );\nvar complexDType = require( '@stdlib/complex-dtype' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar Number = require( '@stdlib/number-ctor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar boolean2bigint = require( './boolean2bigint.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setBigInt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isDataView = require( '@stdlib/assert-is-dataview' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isStructInstance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStruct;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nmodule.exports = complex2number;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' );\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar dtype = require( '@stdlib/array-dtype' );\nvar reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar map = require( '@stdlib/array-base-map' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar number2boolean = require( './number2boolean.js' );\nvar complex2boolean = require( './complex2boolean.js' );\nvar complex2number = require( './complex2number.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setTypedArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setStructArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar DATA_VIEW_METHODS = require( './data_view_methods.js' );\nvar setNumber = require( './set_number.js' );\nvar setComplex = require( './set_complex.js' );\nvar setBoolean = require( './set_boolean.js' );\nvar setBigInt = require( './set_bigint.js' );\nvar setStruct = require( './set_struct.js' );\nvar setTypedArray = require( './set_typedarray.js' );\nvar setStructArray = require( './set_struct_array.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar getter = require( './getter.js' );\nvar setter = require( './setter.js' );\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = createPrototypeAccessors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nmodule.exports = FIELD_PROPERTIES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnionType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasProp = require( '@stdlib/assert-has-property' );\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nmodule.exports = hasProperties;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidNonEmptyString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidPositiveInteger;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidBoolean;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nmodule.exports = DTYPES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar DTYPES = require( './dtypes.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidType;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = isValidOneOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = initFieldObject;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteLength;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nmodule.exports = CASTING_MODES;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nmodule.exports = ALIGNMENTS;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar join = require( '@stdlib/array-base-join' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar format = require( '@stdlib/string-format' );\nvar hasProperties = require( './has_properties.js' );\nvar isValidNonEmptyString = require( './is_valid_nonempty_string.js' );\nvar isValidString = require( './is_valid_string.js' );\nvar isValidPositiveInteger = require( './is_valid_positive_integer.js' );\nvar isValidBoolean = require( './is_valid_boolean.js' );\nvar isValidType = require( './is_valid_type.js' );\nvar isValidOneOf = require( './is_valid_one_of.js' );\nvar initFieldObject = require( './init_field_object.js' );\nvar byteLength = require( './byte_length.js' );\nvar CASTING_MODES = require( './casting_modes.js' );\nvar ALIGNMENTS = require( './alignments.js' );\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nmodule.exports = alignment;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalizeUnion;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-object' );\nvar format = require( '@stdlib/string-format' );\nvar FIELD_PROPERTIES = require( './field_properties.js' );\nvar isUnionType = require( './is_union_type.js' );\nvar normalizeField = require( './normalize_field.js' );\nvar normalizeUnion = require( './normalize_union.js' );\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = normalize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar format = require( '@stdlib/string-format' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldNames;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar indexOf = require( '@stdlib/array-base-index-of' );\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fieldIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar isUnionType = require( './is_union_type.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nmodule.exports = byteOffsets;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = partitions;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isUnionType = require( './is_union_type.js' );\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = flatten;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linearFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-base-replace' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = layoutFormat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar join = require( '@stdlib/array-base-join' );\nvar format = require( '@stdlib/string-format' );\nvar linearFormat = require( './format_linear.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar typedarray2json = require( '@stdlib/array-to-json' );\nvar isStructInstance = require( './is_struct_instance.js' );\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar hasProp = require( '@stdlib/assert-has-property' );\nvar min = require( '@stdlib/math-base-special-fast-min' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar format = require( '@stdlib/string-format' );\nvar PRIVATE_BUFFER = require( './private_buffer.js' );\nvar CTOR_NAME = require( './ctor_name.js' );\nvar createPrototypeAccessors = require( './create_prototype_accessors.js' );\nvar isStructInstance = require( './is_struct_instance.js' );\nvar normalize = require( './normalize_field_list.js' );\nvar fieldNames = require( './field_names.js' );\nvar fieldIndex = require( './field_index.js' );\nvar resolveAlignment = require( './resolve_alignment.js' );\nvar byteOffsets = require( './byte_offsets.js' );\nvar partitions = require( './partitions.js' );\nvar flatten = require( './flatten_fields.js' );\nvar struct2string = require( './to_string.js' );\nvar struct2json = require( './to_json.js' );\nvar layoutFormat = require( './format_layout.js' );\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @module @stdlib/dstructs-struct\n*\n* @example\n* var factory = require( '@stdlib/dstructs-struct' );\n*\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cAuBA,IAAIC,GAAiB,wCAKrBD,GAAO,QAAUC,KC5BjB,IAAAC,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,SAKhBD,GAAO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,GAAA,cA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AgBjB,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAK,UAAU,OAAS,EACvBiB,EAAO,UAAW,CAAE,EAEpBA,EAAO,CAAC,EAEF9B,GAAea,EAAQH,EAAQoB,CAAK,CAC5C,CAAC,EAaDtD,EAAaqC,EAAO,UAAW,SAAU,UAAkB,CAC1D,GAAK,EAAG,gBAAgBA,GACvB,MAAM,IAAI,MAAO,sDAAuD,EAEzE,OAAOZ,GAAa,KAAMS,CAAO,CAClC,CAAC,EAEMG,CACR,CAKAtC,GAAO,QAAU4B,KCrcjB,IAAI4B,GAAO,KAKX,OAAO,QAAUA", - "names": ["require_private_buffer", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "require_ctor_name", "__commonJSMin", "exports", "module", "CTOR_NAME", "require_data_view_methods", "__commonJSMin", "exports", "module", "DATA_VIEW_METHODS", "require_get_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getNumber", "obj", "method", "getter", "view", "require_get_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "Boolean", "PRIVATE_BUFFER", "getBoolean", "obj", "method", "getter", "view", "require_get_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "complex", "PRIVATE_BUFFER", "CMPLX_TO_REAL", "getComplex", "obj", "method", "getter", "view", "re", "im", "require_get_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "PRIVATE_BUFFER", "getBigInt", "obj", "method", "getter", "view", "require_get_struct", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStruct", "obj", "getter", "view", "require_get_typedarray", "__commonJSMin", "exports", "module", "typedarray", "PRIVATE_BUFFER", "getTypedArray", "obj", "getter", "view", "require_get_struct_array", "__commonJSMin", "exports", "module", "PRIVATE_BUFFER", "getStructArray", "obj", "getter", "offset", "view", "out", "i", "require_getter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "getNumber", "getBoolean", "getComplex", "getBigInt", "getStruct", "getTypedArray", "getStructArray", "getter", "obj", "require_boolean2number", "__commonJSMin", "exports", "module", "boolean2number", "value", "require_bigint2number", "__commonJSMin", "exports", "module", "Number", "bigint2number", "value", "require_defaults", "__commonJSMin", "exports", "module", "require_set_number", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isRealFloatingPointDataType", "isSignedIntegerDataType", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "minSignedIntegerDataType", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "defaults", "setNumber", "obj", "method", "setter", "value", "view", "dt", "v", "require_set_complex", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "format", "boolean2number", "bigint2number", "PRIVATE_BUFFER", "setComplex", "obj", "method", "setter", "value", "view", "dt", "re", "im", "require_number2boolean", "__commonJSMin", "exports", "module", "Boolean", "number2boolean", "value", "require_complex2boolean", "__commonJSMin", "exports", "module", "Boolean", "complex2boolean", "value", "require_bigint2boolean", "__commonJSMin", "exports", "module", "Boolean", "bigint2boolean", "value", "require_set_boolean", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isBigInt", "isComplexLike", "isAllowedCast", "complexDType", "Boolean", "format", "PRIVATE_BUFFER", "boolean2number", "number2boolean", "complex2boolean", "bigint2boolean", "defaults", "setBoolean", "obj", "method", "setter", "value", "view", "dt", "v", "require_boolean2bigint", "__commonJSMin", "exports", "module", "BigInt", "boolean2bigint", "value", "require_set_bigint", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "isNumber", "isBoolean", "isInteger", "isBigInt", "isComplexLike", "isAllowedCast", "minDataType", "complexDType", "BigInt", "Number", "floor", "format", "PRIVATE_BUFFER", "boolean2bigint", "defaults", "setBigInt", "obj", "method", "setter", "value", "view", "dt", "v", "require_is_struct_instance", "__commonJSMin", "exports", "module", "isDataView", "isObject", "PRIVATE_BUFFER", "isStructInstance", "value", "require_set_struct", "__commonJSMin", "exports", "module", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "isStructInstance", "setStruct", "obj", "setter", "value", "view", "dest", "src", "buf", "nb", "require_complex2number", "__commonJSMin", "exports", "module", "complex2number", "value", "require_set_typedarray", "__commonJSMin", "exports", "module", "isCollection", "isAllowedCast", "isComplexDataType", "isBooleanDataType", "isRealDataType", "typedarray", "dtype", "reinterpretComplex", "reinterpretBoolean", "gcopy", "gfill", "map", "format", "PRIVATE_BUFFER", "isStructInstance", "number2boolean", "complex2boolean", "complex2number", "setTypedArray", "obj", "setter", "value", "view", "buf", "dt", "require_set_struct_array", "__commonJSMin", "exports", "module", "isCollection", "Uint8Array", "gcopy", "format", "PRIVATE_BUFFER", "setStructArray", "obj", "setter", "values", "offset", "views", "view", "dest", "src", "buf", "nb", "i", "require_setter", "__commonJSMin", "exports", "module", "format", "DATA_VIEW_METHODS", "setNumber", "setComplex", "setBoolean", "setBigInt", "setStruct", "setTypedArray", "setStructArray", "setter", "obj", "require_create_prototype_accessors", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnlyAccessor", "setNonEnumerableReadWriteAccessor", "setReadOnlyAccessor", "setReadWriteAccessor", "getter", "setter", "createPrototypeAccessors", "p", "fields", "get", "set", "out", "o", "i", "require_field_properties", "__commonJSMin", "exports", "module", "FIELD_PROPERTIES", "require_is_union_type", "__commonJSMin", "exports", "module", "isCollection", "isUnionType", "obj", "require_has_properties", "__commonJSMin", "exports", "module", "hasProp", "hasProperties", "obj", "keys", "i", "require_is_valid_nonempty_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidNonEmptyString", "value", "name", "require_is_valid_string", "__commonJSMin", "exports", "module", "isString", "format", "isValidString", "value", "name", "require_is_valid_positive_integer", "__commonJSMin", "exports", "module", "isPositiveInteger", "format", "isValidPositiveInteger", "value", "name", "require_is_valid_boolean", "__commonJSMin", "exports", "module", "isBoolean", "format", "isValidBoolean", "value", "name", "require_dtypes", "__commonJSMin", "exports", "module", "DTYPES", "require_is_valid_type", "__commonJSMin", "exports", "module", "isStructConstructorLike", "contains", "join", "format", "DTYPES", "isValidType", "value", "require_is_valid_one_of", "__commonJSMin", "exports", "module", "contains", "join", "format", "isValidOneOf", "values", "isValid", "value", "name", "require_init_field_object", "__commonJSMin", "exports", "module", "initFieldObject", "require_byte_length", "__commonJSMin", "exports", "module", "bytesPerElement", "byteLength", "obj", "nb", "require_casting_modes", "__commonJSMin", "exports", "module", "CASTING_MODES", "require_alignments", "__commonJSMin", "exports", "module", "ALIGNMENTS", "require_normalize_field", "__commonJSMin", "exports", "module", "isStructConstructorLike", "hasProp", "join", "constantFunction", "format", "hasProperties", "isValidNonEmptyString", "isValidString", "isValidPositiveInteger", "isValidBoolean", "isValidType", "isValidOneOf", "initFieldObject", "byteLength", "CASTING_MODES", "ALIGNMENTS", "MANDATORY_FIELD_NAMES", "VALIDATORS", "normalize", "obj", "keys", "out", "err", "v", "k", "i", "require_resolve_alignment", "__commonJSMin", "exports", "module", "alignment", "fields", "max", "v", "i", "require_normalize_union", "__commonJSMin", "exports", "module", "isObject", "hasProp", "format", "isUnionType", "FIELD_PROPERTIES", "normalizeField", "resolveAlignment", "normalizeUnion", "obj", "fields", "dflg", "out", "tmp", "len", "o", "i", "require_normalize_field_list", "__commonJSMin", "exports", "module", "isObject", "format", "FIELD_PROPERTIES", "isUnionType", "normalizeField", "normalizeUnion", "normalize", "fields", "out", "tmp", "o", "i", "require_field_names", "__commonJSMin", "exports", "module", "format", "isUnionType", "fieldNames", "fields", "hash", "out", "o1", "o2", "i", "j", "k", "require_field_index", "__commonJSMin", "exports", "module", "indexOf", "join", "format", "fieldIndex", "names", "name", "idx", "require_byte_offsets", "__commonJSMin", "exports", "module", "min", "isUnionType", "setPadding", "fields", "padding", "i", "byteOffsets", "max", "alignment", "offset", "tmp", "o", "j", "require_partitions", "__commonJSMin", "exports", "module", "partitions", "fields", "out", "N", "o", "i", "j", "require_flatten_fields", "__commonJSMin", "exports", "module", "isUnionType", "flatten", "fields", "out", "o", "i", "j", "require_format_linear", "__commonJSMin", "exports", "module", "floor", "format", "linearFormat", "Struct", "fields", "nbytes", "fmt0", "fmt1", "fmt2", "bfmt", "ufmt", "fmt", "tmp", "out", "flg", "ib", "c0", "c1", "c2", "w0", "w1", "w", "N", "o", "f", "t", "i", "j", "k", "require_format_layout", "__commonJSMin", "exports", "module", "replace", "format", "reByteOffset", "replacer", "offset", "wrapped", "match", "p1", "layoutFormat", "fields", "out", "tmp", "re", "N", "o", "i", "require_to_string", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "contains", "join", "format", "linearFormat", "layoutFormat", "FORMATS", "isFormat", "toString", "Struct", "fields", "options", "opts", "require_to_json", "__commonJSMin", "exports", "module", "isCollection", "isComplexLike", "isFunction", "typedarray2json", "isStructInstance", "toJSON", "struct", "fields", "out", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "setNonEnumerableReadOnlyAccessor", "isStructConstructorLike", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "hasProp", "min", "filled", "ArrayBuffer", "DataView", "format", "PRIVATE_BUFFER", "CTOR_NAME", "createPrototypeAccessors", "isStructInstance", "normalize", "fieldNames", "fieldIndex", "resolveAlignment", "byteOffsets", "partitions", "flatten", "struct2string", "struct2json", "layoutFormat", "factory", "fields", "FIELD_NAMES", "BYTE_LENGTH", "PARTITIONS", "ALIGNMENT", "ACCESSORS", "FIELDS", "tmp", "o", "Struct", "arg", "byteOffset", "byteLength", "values", "nargs", "cache", "view", "obj", "v", "i", "j", "k", "name", "idx", "value", "buf", "opts", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f4faea6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,140 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'name': 'rejected', - 'description': 'boolean indicating whether the null hypothesis was rejected', - 'type': 'bool', - 'enumerable': true, - 'writable': false, - 'castingMode': 'none' - }, - { - 'name': 'alpha', - 'description': 'significance level', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'pValue', - 'description': 'p-value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'statistic', - 'description': 'test statistic', - 'type': 'float64', - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'ci', - 'description': 'confidence interval', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'df', - 'description': 'degrees of freedom', - 'type': 'int32', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'nullValue', - 'description': 'null value', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'mean', - 'description': 'computed mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - }, - { - 'name': 'sd', - 'description': 'standard error of the mean', - 'type': 'float64', - 'enumerable': true, - 'writable': false, - 'castingMode': 'mostly-safe' - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'rejected': true, - 'alpha': 0.05, - 'pValue': 0.01, - 'statistic': 3.14, - 'ci': new Float64Array( [ -5.0, 5.0 ] ), - 'df': 10, - 'nullValue': 1.0, - 'mean': 1.01, - 'sd': 0.025 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'alpha' ); -console.log( 'Offset: %d', offset ); - -var desc = Struct.descriptionOf( 'alpha' ); -console.log( 'Description: %s', desc ); diff --git a/examples/nested_struct.js b/examples/nested_struct.js deleted file mode 100644 index 1131e33..0000000 --- a/examples/nested_struct.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': 'high', - 'description': 'high word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'low', - 'description': 'low word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2(); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'layout' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); diff --git a/examples/union.js b/examples/union.js deleted file mode 100644 index 09b192b..0000000 --- a/examples/union.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': 'uint32', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%s]', words1.join( ', ' ) ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/examples/union_with_complex.js b/examples/union_with_complex.js deleted file mode 100644 index bde0d0b..0000000 --- a/examples/union_with_complex.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var factory = require( './../lib' ); - -var fields = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'z', - 'description': 'double-precision complex floating-point number', - 'type': 'complex128', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'components', - 'description': 'real and imaginary components', - 'type': 'float64', - 'length': 2, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; - -var Struct = factory( fields ); - -var s = new Struct({ - 'z': new Complex128( 3.0, 5.0 ) -}); -// returns - -var byteLength = Struct.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -s.components[ 0 ] = -3.14; -o = s.toJSON(); -console.log( o ); diff --git a/examples/union_with_struct.js b/examples/union_with_struct.js deleted file mode 100644 index 488c7d5..0000000 --- a/examples/union_with_struct.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var toWords = require( '@stdlib/number-float64-base-to-words' ); -var factory = require( './../lib' ); - -var fields1 = [ - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'low' : 'high', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': ( IS_LITTLE_ENDIAN ) ? 'high' : 'low', - 'description': 'word', - 'type': 'uint32', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } -]; -var Struct1 = factory( fields1 ); - -var fields2 = [ - { - 'type': 'union', - 'fields': [ - { - 'name': 'double', - 'description': 'double-precision floating-point number', - 'type': 'float64', - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - }, - { - 'name': 'words', - 'description': 'high and low words', - 'type': Struct1, - 'enumerable': true, - 'writable': true, - 'castingMode': 'none' - } - ] - } -]; -var Struct2 = factory( fields2 ); - -var s = new Struct2({ - 'double': 3.14 -}); -// returns - -var byteLength = Struct2.byteLength; -console.log( 'Byte length: %d', byteLength ); - -var alignment = Struct2.alignment; -console.log( 'Alignment: %d', alignment ); - -var names = Struct2.fields; -console.log( 'Field names: %s', names.join( ', ' ) ); - -var str1 = s.toString({ - 'format': 'linear' -}); -console.log( 'String:\n%s', str1 ); - -var str2 = s.toString({ - 'format': 'layout' -}); -console.log( 'Layout: %s', str2 ); - -var o = s.toJSON(); -console.log( o ); - -var offset = Struct2.byteOffsetOf( 'double' ); -console.log( 'Offset: %d', offset ); - -var words1 = s.words; -console.log( 'Words: [%d, %d]', words1.high, words1.low ); - -var words2 = toWords( 3.14 ); -console.log( 'Words: [%s]', words2.join( ', ' ) ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..400e42f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-struct-constructor-like@v0.1.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-property@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-fast-min@v0.3.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-accessor@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-cmplx@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-floating-point-data-type@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-signed-integer-data-type@esm/index.mjs";import{isPrimitive as x}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import{isPrimitive as O}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as E}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@esm/index.mjs";import S from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@esm/index.mjs";import L from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-allowed-data-type-cast@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-min-dtype@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-min-signed-integer-dtype@esm/index.mjs";import U from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@esm/index.mjs";import I from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import J from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs";import M from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-dataview@v0.2.3-esm/index.mjs";import P from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-real-data-type@esm/index.mjs";import D from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import $ from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import C from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map@esm/index.mjs";import G from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import H from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-constant-function@v0.2.3-esm/index.mjs";import{isPrimitive as K}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as Q}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as W}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.3-esm/index.mjs";import{isPrimitive as X}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import Y,{factory as Z}from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@v0.2.3-esm/index.mjs";import tt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import et from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-contains@esm/index.mjs";import nt from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import st from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import rt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-index-of@v0.3.1-esm/index.mjs";import it from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import at from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import ot from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import lt from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-replace@v0.2.3-esm/index.mjs";import ft from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.4-esm/index.mjs";import dt from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import mt from"https://cdn.jsdelivr.net/gh/stdlib-js/array-to-json@v0.3.1-esm/index.mjs";var ut="__@@##$$@@__struct_buffer__@@$$##@@__",pt={int8:{get:"getInt8",set:"setInt8"},int16:{get:"getInt16",set:"setInt16"},int32:{get:"getInt32",set:"setInt32"},int64:{get:"getBigInt64",set:"setBigInt64"},uint8:{get:"getUint8",set:"setUint8"},uint16:{get:"getUint16",set:"setUint16"},uint32:{get:"getUint32",set:"setUint32"},uint64:{get:"getBigUint64",set:"setBigUint64"},float16:{get:"getFloat16",set:"setFloat16"},float32:{get:"getFloat32",set:"setFloat32"},float64:{get:"getFloat64",set:"setFloat64"},complex32:{get:"getFloat16",set:"setFloat16"},complex64:{get:"getFloat32",set:"setFloat32"},complex128:{get:"getFloat64",set:"setFloat64"},bool:{get:"getUint8",set:"setUint8"}};var ct={complex128:"float64",complex64:"float32",complex32:"float16"};function gt(t){if(t.length)return t.isStructType?function(t){return function(){var e,n,s,r;for(e=(n=this[ut]).byteOffset+t.byteOffset,s=[],r=0;r0?null:new TypeError(u("invalid argument. `%s` field must be a non-empty string. Value: `%s`.",e,t))},type:function(t){return Y(Ft,t)||n(t)?null:new TypeError(I('invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.',"type",tt(Ft,", "),t))},description:function(t,e){return Q(t)?null:new TypeError(u("invalid argument. `%s` field must be a string. Value: `%s`.",e,t))},length:function(t,e){return W(t)?null:new TypeError(u("invalid argument. `%s` field must be a positive integer. Value: `%s`.",e,t))},enumerable:Vt,writable:Vt,default:H(null),castingMode:(Ut=["none","safe","mostly-safe","same-kind","unsafe"],function(t,e){return et(Ut,t)?null:new TypeError(I('invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.',e,tt(Ut,", "),t))})};function kt(t,e){var s,r,i,a,l;for(s={isStructType:!1,description:"",byteLength:0,byteOffset:0,alignment:0,padding:0,enumerable:!0,writable:!0,default:void 0,castingMode:"none"},l=0;le&&(e=n);return e}function _t(t){var e,n,s,r,i,a,l;if(0===(e=t.fields).length)return null;for(s=[],l=0;l0&&i.byteOffset===t[a-1].byteOffset||(i.isStructType?e.push(lt(i.type.layout,s,Bt(i.byteOffset))):e.push(u("|<%s>[%u,%u]",i.type,i.byteOffset,i.byteLength)));return"|"===(n=u("%s|",e.join("")))[n.length-2]&&(n=n.substring(0,n.length-1)),n}var Dt=["none","linear","layout"],$t=Z(Dt);function zt(t,e,n){var s;if(!it(n))throw new TypeError(u("null2V",n));if(s={format:"none"},at(n,"format")&&(s.format=n.format,!$t(s.format)))throw new TypeError(u("null4S","format",G(Dt,", "),n.format));return"linear"===s.format?function(t,e){var n,s,r,i,a,o,l,f,d,m,p,c,g,h,y,b,v,j,w,x,O,E;for(b=e.length,n="%"+(t.byteLength-1).toString().length+"s",h=0,x=0;xh&&(h=y);for(s="%"+h+"s",r="// %s",o="%s: %s %s",m=0,f=[],x=0;x0&&v.byteOffset===e[x-1].byteOffset)){for(d=x1?" (byte %u)":"",d){for(a=" => union: %s",l=[],E=x+1;E":j.type,l.push(u("%s<%s>[%u]",j.name,w,O%j.alignment)),E+=1;a=u(a,l.join(", "))}else a="";l=u(i+a,O%v.alignment),g=v.length?u(r,u("%s[%u]%s",v.type,ot(O/v.alignment),l)):u(r,u("%s%s",v.type,l)),f.push(u(o,p,c,g)),m+=1}for(O=0;O"}function qt(h){var y,b,v,j,w,x,O,E;if(!r(h))throw new TypeError(u("null2O",h));if(O=function(t){var e,n,s,r;for(e=[],r=0;r0){if(!a(e))throw new TypeError(u("null3L",e));j=e}if(t(this,ut,h),void 0!==j){for(p=f(void 0,x.length),g={},S=0;S0&&((i=t[o-1]).padding=s,Lt(a)&&Pt(i.fields,s)),a.byteOffset=r,Lt(a))for(f=0;f0?arguments[0]:{})})),t(T.prototype,"toJSON",(function(){if(!(this instanceof T))throw new Error("invalid invocation. `this` is not a struct instance.");return function(t,e){var n,s,i,a;for(n={},a=0;a} result\n\t*/\n\tfunction getter() {\n\t\tvar offset;\n\t\tvar view;\n\t\tvar out;\n\t\tvar i;\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tout = [];\n\t\tfor ( i = 0; i < obj.length; i++ ) {\n\t\t\tout.push( new obj.type( view.buffer, offset, obj.byteLength ) );\n\t\t\toffset += obj.byteOffset;\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport typedarray from '@stdlib/array-typed';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getTypedArray( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {TypedArray} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBigInt( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a BigInt value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {BigInt} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport Boolean from '@stdlib/boolean-ctor';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for resolving field data\n*/\nfunction getBoolean( obj, method ) {\n\treturn getter;\n\n\t/**\n\t* Reads a boolean value from an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {boolean} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for resolving field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for resolving field data\n*/\nfunction getStruct( obj ) {\n\treturn getter;\n\n\t/**\n\t* Returns a `struct` view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @returns {Object} result\n\t*/\n\tfunction getter() {\n\t\tvar view = this[ PRIVATE_BUFFER ];\n\t\treturn new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a boolean to a number.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2number( value ) {\n\treturn ( value ) ? 1 : 0;\n}\n\n\n// EXPORTS //\n\nexport default boolean2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a number.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {number} result\n*/\nfunction bigint2number( value ) {\n\treturn Number( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a number to a boolean.\n*\n* @private\n* @param {number} value - input value\n* @returns {boolean} result\n*/\nfunction number2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default number2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a complex number to a boolean.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {boolean} result\n*/\nfunction complex2boolean( value ) {\n\treturn Boolean( value.re || value.im );\n}\n\n\n// EXPORTS //\n\nexport default complex2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport Boolean from '@stdlib/boolean-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2number from './boolean2number.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport bigint2boolean from './bigint2boolean.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBoolean( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a boolean value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = defaults.dtypes.real;\n\t\t\tv = boolean2number( number2boolean( value ) );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = boolean2number( bigint2boolean( value ) );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = boolean2number( complex2boolean( value ) );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = Boolean( value );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a BigInt to a boolean.\n*\n* @private\n* @param {BigInt} value - input value\n* @returns {boolean} result\n*/\nfunction bigint2boolean( value ) {\n\treturn Boolean( value );\n}\n\n\n// EXPORTS //\n\nexport default bigint2boolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport BigInt from '@stdlib/bigint-ctor';\nimport Number from '@stdlib/number-ctor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport boolean2bigint from './boolean2bigint.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setBigInt( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // FIXME: support both int64 and uint64\n\t\t\tv = value;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tif ( isInteger( value ) ) {\n\t\t\t\tdt = minDataType( value );\n\t\t\t\tv = BigInt( value );\n\t\t\t} else {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t\tv = BigInt( floor( value ) );\n\t\t\t}\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2bigint( value );\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || defaults.dtypes.complex;\n\t\t\tv = BigInt( floor( value.re ) ); // discard imaginary component\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = BigInt( floor( Number( v ) ) );\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setBigInt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BigInt from '@stdlib/bigint-ctor';\n\n\n// MAIN //\n\n/**\n* Converts a boolean to a BigInt.\n*\n* @private\n* @param {boolean} value - input value\n* @returns {number} result\n*/\nfunction boolean2bigint( value ) {\n\treturn BigInt( ( value ) ? 1 : 0 );\n}\n\n\n// EXPORTS //\n\nexport default boolean2bigint;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from '@stdlib/assert-is-dataview';\nimport isObject from '@stdlib/assert-is-object';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `struct` instance.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `struct` instance\n*/\nfunction isStructInstance( value ) {\n\t// NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further \"brand\" checks...\n\treturn (\n\t\tisObject( value ) &&\n\t\tisDataView( value[ PRIVATE_BUFFER ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isStructInstance;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a complex number to a number.\n*\n* @private\n* @param {ComplexLike} value - input value\n* @returns {number} result\n*/\nfunction complex2number( value ) {\n\treturn value.re;\n}\n\n\n// EXPORTS //\n\nexport default complex2number;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DATA_VIEW_METHODS from './data_view_methods.js';\nimport setNumber from './set_number.js';\nimport setComplex from './set_complex.js';\nimport setBoolean from './set_boolean.js';\nimport setBigInt from './set_bigint.js';\nimport setStruct from './set_struct.js';\nimport setTypedArray from './set_typedarray.js';\nimport setStructArray from './set_struct_array.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for setting field data.\n*\n* @private\n* @param {Object} obj - field object\n* @throws {Error} unexpected error\n* @returns {Function} function for setting field data\n*/\nfunction setter( obj ) {\n\tif ( obj.length ) {\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStructArray( obj );\n\t\t}\n\t\treturn setTypedArray( obj );\n\t}\n\tswitch ( obj.type ) {\n\tcase 'float64':\n\tcase 'float32':\n\tcase 'float16':\n\tcase 'int8':\n\tcase 'int16':\n\tcase 'int32':\n\tcase 'uint8':\n\tcase 'uint16':\n\tcase 'uint32':\n\t\treturn setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'int64':\n\tcase 'uint64':\n\t\treturn setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'bool':\n\t\treturn setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tcase 'complex128':\n\tcase 'complex64':\n\tcase 'complex32':\n\t\treturn setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set );\n\n\tdefault:\n\t\tif ( obj.isStructType ) {\n\t\t\treturn setStruct( obj );\n\t\t}\n\t\t// Ensure that we fail loudly if we have failed to add support for newly added data types:\n\t\tthrow new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStructArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of `struct` instances to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} values - list of `struct` instances\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( values ) {\n\t\tvar offset;\n\t\tvar views;\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tvar i;\n\n\t\tif ( !isCollection( values ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) );\n\t\t}\n\t\tif ( values.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tif ( obj.casting === 'none' ) {\n\t\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\t\tif ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances\n\t\t\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Compute the expected number of bytes per struct view:\n\t\tnb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements\n\n\t\t// Check that all struct instances have the same byte length...\n\t\tviews = [];\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tbuf = this.constructor.viewOf( values[ i ] );\n\t\t\tif ( buf.byteLength !== nb ) {\n\t\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) );\n\t\t\t}\n\t\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\t\t\tviews.push( src );\n\t\t}\n\t\t// Write the data for each `struct` to the underlying byte buffer...\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\toffset = view.byteOffset + obj.byteOffset;\n\t\tfor ( i = 0; i < values.length; i++ ) {\n\t\t\tdest = new Uint8Array( view.buffer, offset, nb );\n\t\t\tgcopy( obj.length, views[ i ], 1, dest, 1 );\n\t\t\toffset += nb;\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStructArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport isComplexDataType from '@stdlib/array-base-assert-is-complex-floating-point-data-type';\nimport isBooleanDataType from '@stdlib/array-base-assert-is-boolean-data-type';\nimport isRealDataType from '@stdlib/array-base-assert-is-real-data-type';\nimport typedarray from '@stdlib/array-typed';\nimport dtype from '@stdlib/array-dtype';\nimport reinterpretComplex from '@stdlib/strided-base-reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport gfill from '@stdlib/blas-ext-base-gfill';\nimport map from '@stdlib/array-base-map';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\nimport number2boolean from './number2boolean.js';\nimport complex2boolean from './complex2boolean.js';\nimport complex2number from './complex2number.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setTypedArray( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes a list of values to a typed array view of an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Collection} value - value to set\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {RangeError} must provide an array-like object having an expected length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar buf;\n\t\tvar dt;\n\t\tif ( !isCollection( value ) || isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( value.length !== obj.length ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) );\n\t\t}\n\t\tdt = dtype( value );\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tbuf = this[ PRIVATE_BUFFER ];\n\t\tview = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type );\n\t\tif ( dt === obj.type ) {\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: boolean => boolean\n\t\t\tif ( isBooleanDataType( dt ) ) {\n\t\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => real\n\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: real => ???\n\t\tif ( isRealDataType( dt ) ) {\n\t\t\t// Case: real => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length, value, 1, view, 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tview = reinterpretComplex( view, 0 );\n\n\t\t\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\t\t\tgcopy( obj.length, view, 2, value, 1 ); // assign to only real-components\n\t\t\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: real => boolean\n\t\t\tmap.assign( value, view, 1, 0, number2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: complex => ???\n\t\tif ( isComplexDataType( dt ) ) {\n\t\t\t// Case: complex => real\n\t\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\t\tmap.assign( value, view, 1, 0, complex2number ); // discard imaginary components\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => complex\n\t\t\tif ( isComplexDataType( obj.type ) ) {\n\t\t\t\tgcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Case: complex => boolean\n\t\t\tmap.assign( value, view, 1, 0, complex2boolean );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => ???\n\n\t\t// Case: boolean => real\n\t\tif ( isRealDataType( obj.type ) ) {\n\t\t\tgcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 );\n\t\t\treturn;\n\t\t}\n\t\t// Case: boolean => complex\n\t\tview = reinterpretComplex( view, 0 );\n\n\t\t// TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays\n\t\tgcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components\n\t\tgfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport isRealFloatingPointDataType from '@stdlib/array-base-assert-is-real-floating-point-data-type'; // eslint-disable-line id-length\nimport isSignedIntegerDataType from '@stdlib/array-base-assert-is-signed-integer-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport minDataType from '@stdlib/array-min-dtype';\nimport minSignedIntegerDataType from '@stdlib/array-base-min-signed-integer-dtype';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setNumber( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a number value to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar v;\n\t\tif ( isNumber( value ) ) {\n\t\t\tif ( isRealFloatingPointDataType( obj.type ) ) {\n\t\t\t\tdt = obj.type;\n\t\t\t} else if ( !isInteger( value ) ) {\n\t\t\t\tdt = defaults.dtypes.real;\n\t\t\t} else if ( isSignedIntegerDataType( obj.type ) ) {\n\t\t\t\tdt = minSignedIntegerDataType( value );\n\t\t\t} else {\n\t\t\t\tdt = minDataType( value );\n\t\t\t}\n\t\t\tv = value;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' );\n\t\t\tv = value.re; // discard imaginary component\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tv = boolean2number( value );\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tv = bigint2number( value );\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tv = value;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this, max-len */\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isBigInt } from '@stdlib/assert-is-bigint';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isAllowedCast from '@stdlib/ndarray-base-assert-is-allowed-data-type-cast';\nimport complexDType from '@stdlib/complex-dtype';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport boolean2number from './boolean2number.js';\nimport bigint2number from './bigint2number.js';\nimport PRIVATE_BUFFER from './private_buffer.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @param {string} method - data view method name\n* @returns {Function} function for writing field data\n*/\nfunction setComplex( obj, method ) {\n\treturn setter;\n\n\t/**\n\t* Writes a complex number to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dt;\n\t\tvar re;\n\t\tvar im;\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tdt = complexDType( value ) || obj.type;\n\t\t\tre = value.re;\n\t\t\tim = value.im;\n\t\t} else if ( isNumber( value ) ) {\n\t\t\tdt = ( obj.type === 'complex64' ) ? 'float32' : 'float64';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t} else if ( isBigInt( value ) ) {\n\t\t\tdt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here\n\t\t\tre = bigint2number( value );\n\t\t\tim = 0.0;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = 'bool';\n\t\t\tre = boolean2number( value );\n\t\t\tim = 0.0;\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t\tre = value;\n\t\t\tim = 0.0;\n\t\t}\n\t\tif ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) );\n\t\t}\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tview[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN );\n\t\tview[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setComplex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array-uint8';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for writing field data.\n*\n* @private\n* @param {Object} obj - field object\n* @returns {Function} function for writing field data\n*/\nfunction setStruct( obj ) {\n\treturn setter;\n\n\t/**\n\t* Writes `struct` data to an underlying byte buffer.\n\t*\n\t* @private\n\t* @param {Object} value - value to set\n\t* @throws {TypeError} must be a `struct` instance\n\t* @throws {RangeError} must be a `struct` instance having the same byte length\n\t* @throws {TypeError} cannot cast provided values to field data type\n\t*/\n\tfunction setter( value ) {\n\t\tvar view;\n\t\tvar dest;\n\t\tvar src;\n\t\tvar buf;\n\t\tvar nb;\n\t\tif ( !isStructInstance( value ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tif ( obj.casting === 'none' && !( value instanceof obj.type ) ) {\n\t\t\tthrow new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) );\n\t\t}\n\t\tnb = obj.byteLength;\n\n\t\tbuf = this.constructor.viewOf( value );\n\t\tif ( buf.byteLength !== nb ) {\n\t\t\tthrow new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) );\n\t\t}\n\t\tsrc = new Uint8Array( buf.buffer, buf.byteOffset, nb );\n\n\t\tview = this[ PRIVATE_BUFFER ];\n\t\tdest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len\n\n\t\tgcopy( obj.length, src, 1, dest, 1 );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default setStruct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar FIELD_PROPERTIES = [\n\t'name',\n\t'type',\n\t'description',\n\t'length',\n\t'enumerable',\n\t'writable',\n\t'default',\n\t'castingMode'\n];\n\n\n// EXPORTS //\n\nexport default FIELD_PROPERTIES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating whether a field object represents a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {boolean} result\n*/\nfunction isUnionType( obj ) {\n\treturn obj.type === 'union' && isCollection( obj.fields );\n}\n\n\n// EXPORTS //\n\nexport default isUnionType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid boolean field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidBoolean( value, name ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar DTYPES = [\n\t'int8',\n\t'int16',\n\t'int32',\n\t'int64',\n\n\t'uint8',\n\t'uint16',\n\t'uint32',\n\t'uint64',\n\n\t// 'float16', // TODO: uncomment once supported\n\n\t'float32',\n\t'float64',\n\n\t// 'complex32', // TODO: uncomment once supported\n\n\t'complex64',\n\t'complex128',\n\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CASTING_MODES = [\n\t'none',\n\t'safe',\n\t'mostly-safe',\n\t'same-kind',\n\t'unsafe'\n];\n\n\n// EXPORTS //\n\nexport default CASTING_MODES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns a function for testing whether a provided value is a valid enumerated field.\n*\n* @private\n* @param {Collection} values - list of possible values\n* @returns {Function} output function\n*/\nfunction isValidOneOf( values ) {\n\treturn isValid;\n\n\t/**\n\t* Tests whether a provided value is a valid enumerated field.\n\t*\n\t* @private\n\t* @param {*} value - input value\n\t* @param {string} name - field name\n\t* @returns {(null|TypeError)} error object or null\n\t*/\n\tfunction isValid( value, name ) {\n\t\tif ( contains( values, value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid argument. `%s` field must be one of the following: \"%s\". Value: `%s`.', name, join( values, ', ' ), value ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default isValidOneOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ALIGNMENTS = {\n\t'int8': 1,\n\t'int16': 2,\n\t'int32': 4,\n\t'int64': 8,\n\n\t'uint8': 1,\n\t'uint16': 2,\n\t'uint32': 4,\n\t'uint64': 8,\n\n\t'float16': 2,\n\t'float32': 4,\n\t'float64': 8,\n\n\t'complex32': 2, // same as float16\n\t'complex64': 4, // same as float32\n\t'complex128': 8, // same as float64\n\n\t'bool': 1\n};\n\n\n// EXPORTS //\n\nexport default ALIGNMENTS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport hasProp from '@stdlib/assert-has-property';\nimport join from '@stdlib/array-base-join';\nimport constantFunction from '@stdlib/utils-constant-function';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport hasProperties from './has_properties.js';\nimport isValidNonEmptyString from './is_valid_nonempty_string.js';\nimport isValidString from './is_valid_string.js';\nimport isValidPositiveInteger from './is_valid_positive_integer.js';\nimport isValidBoolean from './is_valid_boolean.js';\nimport isValidType from './is_valid_type.js';\nimport isValidOneOf from './is_valid_one_of.js';\nimport initFieldObject from './init_field_object.js';\nimport byteLength from './byte_length.js';\nimport CASTING_MODES from './casting_modes.js';\nimport ALIGNMENTS from './alignments.js';\n\n\n// VARIABLES //\n\nvar MANDATORY_FIELD_NAMES = [\n\t'name',\n\t'type'\n];\n\nvar VALIDATORS = {\n\t'name': isValidNonEmptyString,\n\t'type': isValidType,\n\t'description': isValidString,\n\t'length': isValidPositiveInteger,\n\t'enumerable': isValidBoolean,\n\t'writable': isValidBoolean,\n\t'default': constantFunction( null ),\n\t'castingMode': isValidOneOf( CASTING_MODES )\n};\n\n\n// MAIN //\n\n/**\n* Normalizes a provided field object.\n*\n* @private\n* @param {Object} obj - input field object\n* @param {Array} keys - list of keys to standardize\n* @returns {(Object|Error)} output object or an error\n*/\nfunction normalize( obj, keys ) {\n\tvar out;\n\tvar err;\n\tvar v;\n\tvar k;\n\tvar i;\n\n\tout = initFieldObject();\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tif ( hasProp( obj, k ) ) {\n\t\t\tv = obj[ k ];\n\t\t\terr = VALIDATORS[ k ]( v, k );\n\t\t\tif ( err ) {\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\tout[ k ] = v;\n\t\t}\n\t}\n\tif ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Field objects must have the following properties: \"%s\". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) );\n\t}\n\tout.isStructType = isStructConstructorLike( out.type );\n\tout.byteLength = byteLength( out );\n\tif ( out.isStructType ) {\n\t\tout.alignment = out.type.alignment;\n\t} else {\n\t\tout.alignment = ALIGNMENTS[ out.type ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidNonEmptyString( value, name ) {\n\tif ( isString( value ) || value.length > 0 ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidNonEmptyString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport contains from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid `type` field.\n*\n* @private\n* @param {*} value - input value\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidType( value ) {\n\tif ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: \"%s\". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid string field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidString( value, name ) {\n\tif ( isString( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isPositiveInteger } from '@stdlib/assert-is-positive-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Tests whether a provided value is a valid positive integer field.\n*\n* @private\n* @param {*} value - input value\n* @param {string} name - field name\n* @returns {(null|TypeError)} error object or null\n*/\nfunction isValidPositiveInteger( value, name ) {\n\tif ( isPositiveInteger( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) );\n}\n\n\n// EXPORTS //\n\nexport default isValidPositiveInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an initialized field object.\n*\n* @private\n* @returns {Object} initialized field object\n*/\nfunction initFieldObject() {\n\treturn {\n\t\t'isStructType': false,\n\t\t'description': '',\n\t\t'byteLength': 0,\n\t\t'byteOffset': 0,\n\t\t'alignment': 0,\n\t\t'padding': 0,\n\t\t'enumerable': true,\n\t\t'writable': true,\n\t\t'default': void 0, // explicitly set to `undefined`\n\t\t'castingMode': 'none'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default initFieldObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasProp from '@stdlib/assert-has-property';\n\n\n// MAIN //\n\n/**\n* Tests whether an object has a list of properties.\n*\n* @private\n* @param {Object} obj - input object\n* @param {Array} keys - list of property names\n* @returns {boolean} result\n*/\nfunction hasProperties( obj, keys ) {\n\tvar i;\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tif ( !hasProp( obj, keys[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes required to store a field value.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {PositiveInteger} number of bytes\n*/\nfunction byteLength( obj ) {\n\tvar nb;\n\tif ( obj.isStructType ) {\n\t\tnb = obj.type.byteLength;\n\t} else {\n\t\tnb = bytesPerElement( obj.type );\n\t}\n\tif ( obj.length ) {\n\t\tnb *= obj.length;\n\t}\n\treturn nb;\n}\n\n\n// EXPORTS //\n\nexport default byteLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves the struct's byte alignment.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {PositiveInteger} alignment\n*/\nfunction alignment( fields ) {\n\tvar max;\n\tvar v;\n\tvar i;\n\n\tmax = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tv = fields[ i ].alignment;\n\t\tif ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max;\n}\n\n\n// EXPORTS //\n\nexport default alignment;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport normalizeField from './normalize_field.js';\nimport resolveAlignment from './resolve_alignment.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a field object representing a union type.\n*\n* @private\n* @param {Object} obj - input field object\n* @returns {(Object|null|Error)} normalized field object or error object\n*/\nfunction normalizeUnion( obj ) {\n\tvar fields;\n\tvar dflg;\n\tvar out;\n\tvar tmp;\n\tvar len;\n\tvar o;\n\tvar i;\n\n\tfields = obj.fields;\n\tif ( fields.length === 0 ) {\n\t\treturn null;\n\t}\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( isUnionType( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tif ( dflg === void 0 && hasProp( o, 'default' ) ) {\n\t\t\tdflg = true;\n\t\t} else if ( dflg === true && hasProp( o, 'default' ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\tif ( tmp instanceof Error ) {\n\t\t\treturn tmp;\n\t\t}\n\t\tif ( i === 0 ) {\n\t\t\tlen = tmp.byteLength;\n\t\t} else if ( tmp.byteLength !== len ) {\n\t\t\treturn new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn {\n\t\t'type': 'union',\n\t\t'fields': out,\n\t\t'byteLength': len,\n\t\t'byteOffset': 0,\n\t\t'alignment': resolveAlignment( out ),\n\t\t'padding': 0\n\t};\n}\n\n\n// EXPORTS //\n\nexport default normalizeUnion;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport indexOf from '@stdlib/array-base-index-of';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index of a specified field name in a provided list of field names.\n*\n* @private\n* @param {Array} names - list of field names\n* @param {string} name - field name\n* @throws {Error} struct must have at least one field\n* @throws {TypeError} must provide a recognized field name\n* @returns {(integer|Error)} index or an error object\n*/\nfunction fieldIndex( names, name ) {\n\tvar idx;\n\tif ( names.length === 0 ) {\n\t\treturn new Error( 'invalid operation. struct does not have any fields.' );\n\t}\n\tidx = indexOf( names, name, 0 );\n\tif ( idx < 0 ) {\n\t\treturn new TypeError( format( 'invalid argument. Field name must be one of the following: \"%s\". Value: `%s`.', join( names, ', ' ), name ) );\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default fieldIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport min from '@stdlib/math-base-special-fast-min';\nimport isUnionType from './is_union_type.js';\n\n\n// FUNCTIONS //\n\n/**\n* Sets alignment padding for one or more field objects.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {NonNegativeInteger} padding - alignment padding\n* @returns {Array} input array\n*/\nfunction setPadding( fields, padding ) {\n\tvar i;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\tfields[ i ].padding = padding;\n\t}\n\treturn fields;\n}\n\n\n// MAIN //\n\n/**\n* Computes the byte offset for each field.\n*\n* ## Notes\n*\n* - This function mutates each field object.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @param {PositiveInteger} max - maximum alignment\n* @returns {Array} input array\n*/\nfunction byteOffsets( fields, max ) {\n\tvar alignment;\n\tvar padding;\n\tvar offset;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\toffset = 0;\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Resolve the alignment requirement for this field:\n\t\talignment = min( o.alignment, max );\n\n\t\t// Align the current offset to the required boundary:\n\t\tpadding = ( alignment-(offset%alignment) ) % alignment;\n\t\toffset += padding;\n\n\t\t// Set the padding for the previous member:\n\t\tif ( i > 0 ) {\n\t\t\ttmp = fields[ i-1 ];\n\t\t\ttmp.padding = padding;\n\t\t\tif ( isUnionType( o ) ) {\n\t\t\t\tsetPadding( tmp.fields, padding );\n\t\t\t}\n\t\t}\n\t\t// Set the offset for the current member:\n\t\to.byteOffset = offset;\n\n\t\t// If the current member is a union type, propagate the offset to its child field objects...\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\to.fields[ j ].byteOffset = offset;\n\t\t\t}\n\t\t}\n\t\t// Advance the offset by the size, in bytes, of the member:\n\t\toffset += o.byteLength;\n\t}\n\t// Compute the padding for the last member:\n\tpadding = ( alignment - (offset%alignment) ) % alignment;\n\n\t// Set the padding for the last member:\n\to.padding = padding;\n\n\t// If the last member is a union type, propagate the offset to its child field objects...\n\tif ( isUnionType( o ) ) {\n\t\tsetPadding( o.fields, padding );\n\t}\n\n\treturn fields;\n}\n\n\n// EXPORTS //\n\nexport default byteOffsets;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string-base-replace';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a new regular expression for matching byte parameters.\n*\n* @private\n* @returns {RegExp} regular expression\n*/\nfunction reByteOffset() {\n\treturn /\\[(\\d{1,}),/g;\n}\n\n/**\n* Returns a function for replacing byte values in a serialized struct.\n*\n* @private\n* @param {NonNegativeInteger} offset - byte offset\n* @returns {Function} replacer function\n*/\nfunction replacer( offset ) {\n\treturn wrapped;\n\n\t/**\n\t* Callback invoked for each match.\n\t*\n\t* @private\n\t* @param {string} match - matched substring\n\t* @param {string} p1 - first matched capture group substring\n\t* @returns {string} replacement string\n\t*/\n\tfunction wrapped( match, p1 ) {\n\t\treturn format( '[%u,', offset+parseInt( p1, 10 ) );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a layout format.\n*\n* ## Notes\n*\n* - The output format is a multi-column format having the following layout:\n*\n* ```text\n* | ...[byte_offset,byte_length] |\n* ```\n*\n* For example,\n*\n* ```text\n* |[0,8]|[8,1]|[16,16]|[32,8]|\n* ```\n*\n* @private\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction layoutFormat( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar re;\n\tvar N;\n\tvar o;\n\tvar i;\n\n\tN = fields.length;\n\n\t// Create a new regular expression for matching byte offsets:\n\tre = reByteOffset();\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// If the current type is a struct, we need to serialize and then post-process...\n\t\tif ( o.isStructType ) {\n\t\t\tout.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) );\n\t\t\tcontinue;\n\t\t}\n\t\t// Format the field data:\n\t\tout.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) );\n\t}\n\ttmp = format( '%s|', out.join( '' ) );\n\n\t// If we having a trailing `||` due to a nested struct, remove the final `|`:\n\tif ( tmp[ tmp.length-2 ] === '|' ) {\n\t\ttmp = tmp.substring( 0, tmp.length-1 );\n\t}\n\treturn tmp;\n}\n\n\n// EXPORTS //\n\nexport default layoutFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { factory as contains } from '@stdlib/array-base-assert-contains';\nimport join from '@stdlib/array-base-join';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport linearFormat from './format_linear.js';\nimport layoutFormat from './format_layout.js';\n\n\n// VARIABLES //\n\nvar FORMATS = [\n\t'none',\n\t'linear',\n\t'layout'\n];\nvar isFormat = contains( FORMATS );\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a string.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @param {Options} options - function options\n* @param {string} [options.format] - serialization format\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} string representation\n*/\nfunction toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare\n\tvar opts;\n\tif ( !isPlainObject( options ) ) {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\topts = {\n\t\t'format': 'none'\n\t};\n\tif ( hasOwnProp( options, 'format' ) ) {\n\t\topts.format = options.format;\n\t\tif ( !isFormat( opts.format ) ) {\n\t\t\tthrow new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) );\n\t\t}\n\t}\n\tif ( opts.format === 'linear' ) {\n\t\treturn linearFormat( Struct, fields );\n\t}\n\tif ( opts.format === 'layout' ) {\n\t\treturn layoutFormat( fields );\n\t}\n\t// Case: opts.format === 'none'\n\treturn '';\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Serializes a struct to a linear string format.\n*\n* ## Notes\n*\n* - The output format is a three-column format having the following layout:\n*\n* ```text\n* | byte_number | [field|padding] | notes |\n* ```\n*\n* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance.\n*\n* @private\n* @param {Function} Struct - struct constructor\n* @param {Array} fields - list of normalized fields\n* @returns {string} string representation\n*/\nfunction linearFormat( Struct, fields ) {\n\tvar nbytes;\n\tvar fmt0;\n\tvar fmt1;\n\tvar fmt2;\n\tvar bfmt;\n\tvar ufmt;\n\tvar fmt;\n\tvar tmp;\n\tvar out;\n\tvar flg;\n\tvar ib;\n\tvar c0;\n\tvar c1;\n\tvar c2;\n\tvar w0;\n\tvar w1;\n\tvar w;\n\tvar N;\n\tvar o;\n\tvar f;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = fields.length;\n\n\t// Resolve the size of the struct:\n\tnbytes = Struct.byteLength;\n\n\t// Compute the width of the first column:\n\tw0 = ( nbytes-1 ).toString().length;\n\n\t// Define a format string for the first column:\n\tfmt0 = '%'+w0+'s';\n\n\t// Determine the longest field name...\n\tw1 = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Format: []\n\t\tw = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1;\n\t\tif ( w > w1 ) {\n\t\t\tw1 = w;\n\t\t}\n\t}\n\t// Define a format string for the second column:\n\tfmt1 = '%'+w1+'s';\n\n\t// Define a format string for the third column:\n\tfmt2 = '// %s';\n\n\t// Define a format string which combines the columns:\n\tfmt = '%s: %s %s';\n\n\t// Initialize a byte counter:\n\tib = 0;\n\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// If we are currently processing fields in a union, move along to the next non-union field...\n\t\tif ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Check whether this field is the first field of a union...\n\t\tif ( i < N-1 ) {\n\t\t\tflg = ( o.byteOffset === fields[ i+1 ].byteOffset );\n\t\t} else {\n\t\t\tflg = false;\n\t\t}\n\t\tfor ( j = 0; j < o.byteLength; j++ ) {\n\t\t\t// In the first column, render the byte number:\n\t\t\tc0 = format( fmt0, ib.toString() );\n\n\t\t\t// In the second column, render the field name and the byte number relative to the field:\n\t\t\tc1 = format( fmt1, format( '%s[%u]', o.name, j ) );\n\n\t\t\t// If a field type spans multiple bytes, render the byte number:\n\t\t\tif ( o.alignment > 1 ) {\n\t\t\t\tbfmt = ' (byte %u)';\n\t\t\t} else {\n\t\t\t\tbfmt = '';\n\t\t\t}\n\t\t\t// If a field is part of a union, make that explicit:\n\t\t\tif ( flg ) {\n\t\t\t\tufmt = ' => union: %s';\n\t\t\t\ttmp = [];\n\t\t\t\tk = i + 1;\n\t\t\t\twhile ( k < N && o.byteOffset === fields[ k ].byteOffset ) {\n\t\t\t\t\tf = fields[ k ];\n\t\t\t\t\tif ( f.isStructType ) {\n\t\t\t\t\t\tt = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tt = f.type;\n\t\t\t\t\t}\n\t\t\t\t\ttmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) );\n\t\t\t\t\tk += 1;\n\t\t\t\t}\n\t\t\t\tufmt = format( ufmt, tmp.join( ', ' ) );\n\t\t\t} else {\n\t\t\t\tufmt = '';\n\t\t\t}\n\t\t\ttmp = format( bfmt+ufmt, j%o.alignment );\n\n\t\t\t// If a field contains multiple elements (i.e., is an array), render the field type along with the element number:\n\t\t\tif ( o.length ) {\n\t\t\t\tc2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) );\n\t\t\t}\n\t\t\t// Otherwise, just render the field type:\n\t\t\telse {\n\t\t\t\tc2 = format( fmt2, format( '%s%s', o.type, tmp ) );\n\t\t\t}\n\t\t\t// Render the row string:\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t\tfor ( j = 0; j < o.padding; j++ ) {\n\t\t\tc0 = format( fmt0, ib.toString() );\n\t\t\tc1 = format( fmt1, '--' );\n\t\t\tc2 = format( fmt2, 'padding' );\n\t\t\tout.push( format( fmt, c0, c1, c2 ) );\n\t\t\tib += 1;\n\t\t}\n\t}\n\treturn out.join( '\\n' );\n}\n\n\n// EXPORTS //\n\nexport default linearFormat;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport isStructConstructorLike from '@stdlib/assert-is-struct-constructor-like';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport hasProp from '@stdlib/assert-has-property';\nimport min from '@stdlib/math-base-special-fast-min';\nimport filled from '@stdlib/array-base-filled';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport PRIVATE_BUFFER from './private_buffer.js';\nimport CTOR_NAME from './ctor_name.js';\nimport createPrototypeAccessors from './create_prototype_accessors.js';\nimport isStructInstance from './is_struct_instance.js';\nimport normalize from './normalize_field_list.js';\nimport fieldNames from './field_names.js';\nimport fieldIndex from './field_index.js';\nimport resolveAlignment from './resolve_alignment.js';\nimport byteOffsets from './byte_offsets.js';\nimport partitions from './partitions.js';\nimport flatten from './flatten_fields.js';\nimport struct2string from './to_string.js';\nimport struct2json from './to_json.js';\nimport layoutFormat from './format_layout.js';\n\n\n// MAIN //\n\n/**\n* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`).\n*\n* @param {ObjectArray} fields - structure fields\n* @throws {TypeError} first argument must be an array-like object containing objects\n* @throws {TypeError} field objects must have required properties\n* @throws {TypeError} field objects must have valid fields\n* @throws {TypeError} union types must be array-like objects containing objects\n* @throws {RangeError} union types must contain fields having the same byte length\n* @throws {TypeError} union types cannot contain nested union types\n* @throws {TypeError} union types can only contain one field with a default value\n* @throws {Error} unexpected error\n* @returns {Function} constructor\n*\n* @example\n* var fields = [\n* {\n* 'type': 'union',\n* 'fields': [\n* {\n* 'name': 'double',\n* 'description': 'double-precision floating-point number',\n* 'type': 'float64',\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* },\n* {\n* 'name': 'words',\n* 'description': 'high and low words',\n* 'type': 'uint32',\n* 'length': 2,\n* 'enumerable': true,\n* 'writable': true,\n* 'castingMode': 'none'\n* }\n* ]\n* }\n* ];\n* var Struct = factory( fields );\n*\n* var data = {\n* 'double': 3.14\n* };\n* var s = new Struct( data );\n* // returns \n*\n* var v = s.double;\n* // returns 3.14\n*\n* var w = s.words;\n* // e.g., [ 1374389535, 1074339512 ]\n*/\nfunction factory( fields ) {\n\tvar FIELD_NAMES;\n\tvar BYTE_LENGTH;\n\tvar PARTITIONS;\n\tvar ALIGNMENT;\n\tvar ACCESSORS;\n\tvar FIELDS;\n\tvar tmp;\n\tvar o;\n\tif ( !isCollection( fields ) ) {\n\t\tthrow new TypeError( format( 'null2O', fields ) );\n\t}\n\t// Normalize the list of field objects:\n\ttmp = normalize( fields );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELDS = tmp;\n\n\t// Resolve the list of unique field names:\n\ttmp = fieldNames( FIELDS );\n\tif ( tmp instanceof Error ) {\n\t\tthrow tmp;\n\t}\n\tFIELD_NAMES = tmp;\n\n\t// Resolve the struct's alignment requirements:\n\tALIGNMENT = resolveAlignment( FIELDS );\n\n\t// Compute the byte offset for each field:\n\tFIELDS = byteOffsets( FIELDS, ALIGNMENT );\n\n\t// Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset:\n\tFIELDS = flatten( FIELDS );\n\n\t// Compute field \"partitions\" (i.e., non-overlapping views):\n\tPARTITIONS = partitions( FIELDS );\n\n\t// Compute the struct's byte length:\n\to = FIELDS[ FIELDS.length-1 ];\n\tBYTE_LENGTH = o.byteOffset + o.byteLength + o.padding;\n\n\t/**\n\t* Constructor for a composite data type (a.k.a., a `struct`).\n\t*\n\t* @private\n\t* @param {(Object|ArrayBuffer)} [arg] - array buffer or data object\n\t* @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference\n\t* @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {TypeError} second argument must be a nonnegative integer\n\t* @throws {TypeError} third argument must be a nonnegative integer\n\t* @throws {Error} union types may only be initialized by a single member\n\t* @returns {Struct} struct instance\n\t*/\n\tfunction Struct( arg, byteOffset, byteLength ) {\n\t\tvar values;\n\t\tvar nargs;\n\t\tvar cache;\n\t\tvar view;\n\t\tvar obj;\n\t\tvar o;\n\t\tvar v;\n\t\tvar i;\n\t\tvar j;\n\t\tvar k;\n\n\t\tnargs = arguments.length;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new Struct();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new Struct( arg );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new Struct( arg, byteOffset );\n\t\t\t}\n\t\t\treturn new Struct( arg, byteOffset, byteLength );\n\t\t}\n\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\tview = new DataView( arg, 0, BYTE_LENGTH );\n\t\t\t} else {\n\t\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t\t\t}\n\t\t\t\tif ( nargs === 2 ) {\n\t\t\t\t\tview = new DataView( arg, byteOffset, BYTE_LENGTH );\n\t\t\t\t} else {\n\t\t\t\t\tif ( !isNonNegativeInteger( byteLength ) ) {\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) );\n\t\t\t\t\t}\n\t\t\t\t\tview = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( view.byteLength < BYTE_LENGTH ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) );\n\t\t\t}\n\t\t} else {\n\t\t\tview = new DataView( new ArrayBuffer( BYTE_LENGTH ) );\n\t\t\tif ( nargs > 0 ) {\n\t\t\t\tif ( !isObject( arg ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'null3L', arg ) );\n\t\t\t\t}\n\t\t\t\tobj = arg;\n\t\t\t}\n\t\t}\n\t\t// Bind the byte buffer to the current instance:\n\t\tsetReadOnly( this, PRIVATE_BUFFER, view );\n\n\t\t// If we were provided a data object, set provided fields...\n\t\tif ( obj !== void 0 ) {\n\t\t\t// Initialize an array containing values to set:\n\t\t\tvalues = filled( void 0, FIELDS.length );\n\n\t\t\t// For each field, determine whether a value has been specified...\n\t\t\tcache = {};\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tk = FIELD_NAMES[ i ];\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( hasProp( obj, k ) ) {\n\t\t\t\t\t// Check whether a value has already been specified for this view (i.e., via another union member)...\n\t\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t\tthrow new Error( 'invalid argument. Union types may only be initialized by a single member.' );\n\t\t\t\t\t}\n\t\t\t\t\tvalues[ i ] = obj[ k ];\n\t\t\t\t\tcache[ j ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Perform a second pass over the fields to fill in default initial values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tj = PARTITIONS[ i ];\n\t\t\t\tif ( cache[ j ] ) {\n\t\t\t\t\t// Skip fields already having initial values...\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\to = FIELDS[ i ];\n\t\t\t\tif ( o.default !== void 0 ) {\n\t\t\t\t\tvalues[ i ] = o.default;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Set all fields with initialization values...\n\t\t\tfor ( i = 0; i < FIELDS.length; i++ ) {\n\t\t\t\tv = values[ i ];\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\tACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t* @default 'Struct'\n\t*/\n\tsetReadOnly( Struct, 'name', CTOR_NAME );\n\n\t/**\n\t* Alignment.\n\t*\n\t* @private\n\t* @name alignment\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'alignment', ALIGNMENT );\n\n\t/**\n\t* Size (in bytes) of the `struct`.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof Struct\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( Struct, 'byteLength', BYTE_LENGTH );\n\n\t/**\n\t* Returns a list of `struct` fields.\n\t*\n\t* @private\n\t* @name fields\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Array}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() {\n\t\treturn FIELD_NAMES.slice();\n\t});\n\n\t/**\n\t* Returns a string corresponding to the `struct` layout.\n\t*\n\t* @private\n\t* @name layout\n\t* @memberof Struct\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() {\n\t\t// As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string...\n\t\treturn layoutFormat( FIELDS );\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct`.\n\t*\n\t* @private\n\t* @name bufferOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {ArrayBuffer} underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'bufferOf', function bufferOf( obj ) {\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\treturn obj[ PRIVATE_BUFFER ].buffer;\n\t});\n\n\t/**\n\t* Returns the length, in bytes, of the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteLengthOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte length\n\t*/\n\tsetReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteLength;\n\t});\n\n\t/**\n\t* Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.\n\t*\n\t* @private\n\t* @name byteOffsetOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {NonNegativeInteger} byte offset\n\t*/\n\tsetReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].byteOffset;\n\t});\n\n\t/**\n\t* Returns the description associated with a provided field name.\n\t*\n\t* @private\n\t* @name descriptionOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {string} description\n\t*/\n\tsetReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].description;\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether a provided value is a `struct` instance.\n\t*\n\t* @private\n\t* @name isStruct\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {*} value - input value\n\t* @returns {boolean} boolean indicating whether a value is a `struct` instance\n\t*/\n\tsetReadOnly( Struct, 'isStruct', function isStruct( value ) {\n\t\treturn (\n\t\t\tvalue instanceof Struct ||\n\t\t\t(\n\t\t\t\tisStructInstance( value ) &&\n\t\t\t\tisStructConstructorLike( value.constructor )\n\t\t\t)\n\t\t);\n\t});\n\n\t/**\n\t* Returns the type associated with a provided field name.\n\t*\n\t* @private\n\t* @name typeOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {string} name - field name\n\t* @throws {Error} struct must have at least one field\n\t* @throws {TypeError} must provide a recognized field name\n\t* @returns {(string|Object)} type\n\t*/\n\tsetReadOnly( Struct, 'typeOf', function typeOf( name ) {\n\t\tvar idx = fieldIndex( FIELD_NAMES, name );\n\t\tif ( idx instanceof Error ) {\n\t\t\tthrow idx;\n\t\t}\n\t\treturn FIELDS[ idx ].type;\n\t});\n\n\t/**\n\t* Returns the underlying byte buffer of a `struct` as a `DataView`.\n\t*\n\t* @private\n\t* @name viewOf\n\t* @memberof Struct\n\t* @readonly\n\t* @type {Function}\n\t* @param {Object} obj - struct instance\n\t* @throws {TypeError} must provide a `struct` instance\n\t* @returns {DataView} view of underlying byte buffer\n\t*/\n\tsetReadOnly( Struct, 'viewOf', function viewOf( obj ) {\n\t\tvar buf;\n\t\tif ( !isStructInstance( obj ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) );\n\t\t}\n\t\tbuf = obj[ PRIVATE_BUFFER ];\n\t\treturn new DataView( buf.buffer, buf.byteOffset, buf.byteLength );\n\t});\n\n\t// Create prototype accessors for getting and setting field values:\n\tACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS );\n\n\t/**\n\t* Serializes a `struct` to a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @param {Options} [options] - function options\n\t* @param {string} [options.format='none'] - serialization format\n\t* @throws {Error} `this` must be a struct instance\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toString', function toString() {\n\t\tvar opts;\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\topts = arguments[ 0 ];\n\t\t} else {\n\t\t\topts = {};\n\t\t}\n\t\treturn struct2string( Struct, FIELDS, opts );\n\t});\n\n\t/**\n\t* Serializes a `struct` to JSON.\n\t*\n\t* @private\n\t* @name toJSON\n\t* @memberof Struct.prototype\n\t* @readonly\n\t* @type {Function}\n\t* @throws {Error} `this` must be a struct instance\n\t* @returns {JSON} serialized `struct` instance\n\t*/\n\tsetReadOnly( Struct.prototype, 'toJSON', function toJSON() {\n\t\tif ( !( this instanceof Struct ) ) {\n\t\t\tthrow new Error( 'invalid invocation. `this` is not a struct instance.' );\n\t\t}\n\t\treturn struct2json( this, FIELDS );\n\t});\n\n\treturn Struct;\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport FIELD_PROPERTIES from './field_properties.js';\nimport isUnionType from './is_union_type.js';\nimport normalizeField from './normalize_field.js';\nimport normalizeUnion from './normalize_union.js';\n\n\n// MAIN //\n\n/**\n* Normalizes a list of field objects.\n*\n* @private\n* @param {Array} fields - input fields\n* @returns {(Array|Error)} normalized field objects or an error\n*/\nfunction normalize( fields ) {\n\tvar out;\n\tvar tmp;\n\tvar o;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( !isObject( o ) ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) );\n\t\t}\n\t\t// Check for a union type which is a collection of nested field objects which all have the same byte length...\n\t\tif ( isUnionType( o ) ) {\n\t\t\ttmp = normalizeUnion( o );\n\t\t\tif ( tmp === null ) {\n\t\t\t\treturn new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) );\n\t\t\t}\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t} else {\n\t\t\ttmp = normalizeField( o, FIELD_PROPERTIES );\n\t\t\tif ( tmp instanceof Error ) {\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Resolves a list of field names.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {(Array|Error)} list of field names or an error\n*/\nfunction fieldNames( fields ) {\n\tvar hash;\n\tvar out;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\thash = {};\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to1 = fields[ i ];\n\t\tk = o1.name;\n\t\tif ( isUnionType( o1 ) ) {\n\t\t\tfor ( j = 0; j < o1.fields.length; j++ ) {\n\t\t\t\to2 = o1.fields[ j ];\n\t\t\t\tk = o2.name;\n\t\t\t\tif ( hash[ k ] === true ) {\n\t\t\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t\t\t}\n\t\t\t\thash[ k ] = true;\n\t\t\t\tout.push( k );\n\t\t\t}\n\t\t} else if ( hash[ k ] === true ) {\n\t\t\treturn new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) );\n\t\t} else {\n\t\t\thash[ k ] = true;\n\t\t\tout.push( k );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fieldNames;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUnionType from './is_union_type.js';\n\n\n// MAIN //\n\n/**\n* Flattens a list of field objects.\n*\n* @private\n* @param {Array} fields - list of field objects\n* @returns {Array} new list\n*/\nfunction flatten( fields ) {\n\tvar out;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tout = [];\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tif ( isUnionType( o ) ) {\n\t\t\tfor ( j = 0; j < o.fields.length; j++ ) {\n\t\t\t\tout.push( o.fields[ j ] );\n\t\t\t}\n\t\t} else {\n\t\t\tout.push( o );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a list of partition indices.\n*\n* ## Notes\n*\n* - This function partitions field objects according to whether a field object represents a unique \"view\" over an underlying byte buffer. Field objects within a union belong to the same partition.\n*\n* @private\n* @param {Array} fields - list of normalized field objects\n* @returns {NonNegativeIntegerArray} list of indices\n*/\nfunction partitions( fields ) {\n\tvar out;\n\tvar N;\n\tvar o;\n\tvar i;\n\tvar j;\n\n\tN = fields.length;\n\n\tout = [];\n\tj = 0;\n\tfor ( i = 0; i < N-1; i++ ) {\n\t\to = fields[ i ];\n\n\t\t// Check for the start of a union...\n\t\tif ( o.byteOffset === fields[ i+1 ].byteOffset ) {\n\t\t\tout.push( j );\n\t\t\tcontinue;\n\t\t}\n\t\tout.push( j );\n\t\tj += 1;\n\t}\n\t// Set the partition for the last field object:\n\tout.push( j );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default partitions;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar CTOR_NAME = 'Struct';\n\n\n// EXPORTS //\n\nexport default CTOR_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable id-length */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setNonEnumerableReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnlyAccessor from '@stdlib/utils-define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport getter from './getter.js';\nimport setter from './setter.js';\n\n\n// MAIN //\n\n/**\n* Assigns methods for accessing field values to a provided prototype.\n*\n* @private\n* @param {Object} p - prototype\n* @param {Array} fields - field objects\n* @returns {Object} object containing accessors for each field\n*/\nfunction createPrototypeAccessors( p, fields ) {\n\tvar get;\n\tvar set;\n\tvar out;\n\tvar o;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tget = getter( o );\n\t\tset = setter( o );\n\t\tif ( o.enumerable ) {\n\t\t\tif ( o.writable ) {\n\t\t\t\tsetReadWriteAccessor( p, o.name, get, set );\n\t\t\t} else {\n\t\t\t\tsetReadOnlyAccessor( p, o.name, get );\n\t\t\t}\n\t\t} else if ( o.writable ) {\n\t\t\tsetNonEnumerableReadWriteAccessor( p, o.name, get, set );\n\t\t} else {\n\t\t\tsetNonEnumerableReadOnlyAccessor( p, o.name, get );\n\t\t}\n\t\tout[ o.name ] = [ get, set ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default createPrototypeAccessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert-is-collection';\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport isFunction from '@stdlib/assert-is-function';\nimport typedarray2json from '@stdlib/array-to-json';\nimport isStructInstance from './is_struct_instance.js';\n\n\n// MAIN //\n\n/**\n* Serializes a `struct` instance to JSON.\n*\n* @private\n* @param {Struct} struct - struct instance\n* @param {Array} fields - list of normalized fields\n* @returns {Object} JSON representation\n*/\nfunction toJSON( struct, fields ) {\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < fields.length; i++ ) {\n\t\to = fields[ i ];\n\t\tv = struct[ o.name ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tv = typedarray2json( v );\n\t\t} else if ( isStructInstance( v ) ) {\n\t\t\tv = v.toJSON();\n\t\t} else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) {\n\t\t\tv = v.toJSON();\n\t\t}\n\t\tout[ o.name ] = v;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["PRIVATE_BUFFER","DATA_VIEW_METHODS","int8","get","set","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex32","complex64","complex128","bool","CMPLX_TO_REAL","getter","obj","length","isStructType","offset","view","out","i","this","byteOffset","push","type","buffer","byteLength","getStructArray","typedarray","getTypedArray","method","IS_LITTLE_ENDIAN","getBigInt","Boolean","getBoolean","re","im","complex","getComplex","getStruct","Error","format","boolean2number","value","bigint2number","Number","number2boolean","complex2boolean","setBoolean","dt","v","isBoolean","isNumber","defaults","dtypes","real","isBigInt","bigint2boolean","isComplexLike","complexDType","isAllowedCast","castingMode","TypeError","name","setBigInt","isInteger","minDataType","BigInt","floor","boolean2bigint","isStructInstance","isObject","isDataView","complex2number","setter","values","views","dest","src","buf","nb","isCollection","RangeError","casting","constructor","viewOf","Uint8Array","gcopy","setStructArray","dtype","isComplexDataType","reinterpretComplex","isBooleanDataType","reinterpretBoolean","isRealDataType","gfill","ndarray","map","assign","setTypedArray","isRealFloatingPointDataType","isSignedIntegerDataType","minSignedIntegerDataType","setNumber","setComplex","setStruct","FIELD_PROPERTIES","isUnionType","fields","isValidBoolean","DTYPES","ALIGNMENTS","MANDATORY_FIELD_NAMES","VALIDATORS","isString","contains","isStructConstructorLike","join","description","isPositiveInteger","enumerable","writable","default","constantFunction","normalize","keys","err","k","alignment","padding","hasProp","hasProperties","bytesPerElement","JSON","stringify","max","normalizeUnion","dflg","tmp","len","o","normalizeField","resolveAlignment","fieldIndex","names","idx","indexOf","setPadding","replacer","match","p1","parseInt","layoutFormat","N","replace","layout","substring","FORMATS","isFormat","toString","Struct","options","opts","isPlainObject","hasOwnProp","fmt0","fmt1","fmt2","bfmt","ufmt","fmt","flg","ib","c0","c1","c2","w1","w","f","t","j","linearFormat","factory","FIELD_NAMES","BYTE_LENGTH","PARTITIONS","ALIGNMENT","ACCESSORS","FIELDS","hash","o1","fieldNames","arg","nargs","cache","arguments","isArrayBuffer","DataView","isNonNegativeInteger","min","ArrayBuffer","setReadOnly","filled","call","byteOffsets","flatten","partitions","setNonEnumerableReadOnlyAccessor","slice","p","setReadWriteAccessor","setReadOnlyAccessor","setNonEnumerableReadWriteAccessor","createPrototypeAccessors","prototype","struct2string","struct","typedarray2json","isFunction","toJSON","struct2json"],"mappings":";;kqMAuBA,IAAIA,GAAiB,wCCDjBC,GAAoB,CACvBC,KAAQ,CACPC,IAAO,UACPC,IAAO,WAERC,MAAS,CACRF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C,GAEtCsN,EAAqBF,EAAGrE,EAAE7E,KAAMnE,GAEtBgJ,EAAEnB,SACb2F,EAAmCH,EAAGrE,EAAE7E,KAAMnE,EAAKC,GAEnDkN,EAAkCE,EAAGrE,EAAE7E,KAAMnE,GAE9CuB,EAAKyH,EAAE7E,MAAS,CAAEnE,EAAKC,GAExB,OAAOsB,CACR,CNgZakM,CAA0BrD,EAAOsD,UAAW1B,GAiBxDa,EAAazC,EAAOsD,UAAW,YAAY,WAE1C,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAOlB,OAAO+K,GAAevD,EAAQ4B,EALzBO,UAAUpL,OAAS,EAChBoL,UAAW,GAEX,CAAA,EAGV,IAaCM,EAAazC,EAAOsD,UAAW,UAAU,WACxC,KAAQjM,gBAAgB2I,GACvB,MAAM,IAAIxH,MAAO,wDAElB,OO1dF,SAAiBgL,EAAQ5G,GACxB,IAAIzF,EACAyH,EACA1F,EACA9B,EAGJ,IADAD,EAAM,CAAA,EACAC,EAAI,EAAGA,EAAIwF,EAAO7F,OAAQK,IAE/B8B,EAAIsK,GADJ5E,EAAIhC,EAAQxF,IACE2C,MACTkB,EAAc/B,GAClBA,EAAIuK,GAAiBvK,IACVoB,GAAkBpB,IAElBQ,GAAeR,IAAOwK,GAAYxK,EAAEyK,WAD/CzK,EAAIA,EAAEyK,UAIPxM,EAAKyH,EAAE7E,MAASb,EAEjB,OAAO/B,CACR,CPscSyM,CAAavM,KAAMuK,EAC5B,IAEQ5B,CACR"} \ No newline at end of file diff --git a/lib/alignments.js b/lib/alignments.js deleted file mode 100644 index 10dfc5a..0000000 --- a/lib/alignments.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ALIGNMENTS = { - 'int8': 1, - 'int16': 2, - 'int32': 4, - 'int64': 8, - - 'uint8': 1, - 'uint16': 2, - 'uint32': 4, - 'uint64': 8, - - 'float16': 2, - 'float32': 4, - 'float64': 8, - - 'complex32': 2, // same as float16 - 'complex64': 4, // same as float32 - 'complex128': 8, // same as float64 - - 'bool': 1 -}; - - -// EXPORTS // - -module.exports = ALIGNMENTS; diff --git a/lib/bigint2boolean.js b/lib/bigint2boolean.js deleted file mode 100644 index 7c98fbd..0000000 --- a/lib/bigint2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a boolean. -* -* @private -* @param {BigInt} value - input value -* @returns {boolean} result -*/ -function bigint2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = bigint2boolean; diff --git a/lib/bigint2number.js b/lib/bigint2number.js deleted file mode 100644 index 2282c2c..0000000 --- a/lib/bigint2number.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Number = require( '@stdlib/number-ctor' ); - - -// MAIN // - -/** -* Converts a BigInt to a number. -* -* @private -* @param {BigInt} value - input value -* @returns {number} result -*/ -function bigint2number( value ) { - return Number( value ); -} - - -// EXPORTS // - -module.exports = bigint2number; diff --git a/lib/boolean2bigint.js b/lib/boolean2bigint.js deleted file mode 100644 index d92560a..0000000 --- a/lib/boolean2bigint.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var BigInt = require( '@stdlib/bigint-ctor' ); - - -// MAIN // - -/** -* Converts a boolean to a BigInt. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2bigint( value ) { - return BigInt( ( value ) ? 1 : 0 ); -} - - -// EXPORTS // - -module.exports = boolean2bigint; diff --git a/lib/boolean2number.js b/lib/boolean2number.js deleted file mode 100644 index 9703af4..0000000 --- a/lib/boolean2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a boolean to a number. -* -* @private -* @param {boolean} value - input value -* @returns {number} result -*/ -function boolean2number( value ) { - return ( value ) ? 1 : 0; -} - - -// EXPORTS // - -module.exports = boolean2number; diff --git a/lib/byte_length.js b/lib/byte_length.js deleted file mode 100644 index d205a37..0000000 --- a/lib/byte_length.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); - - -// MAIN // - -/** -* Returns the number of bytes required to store a field value. -* -* @private -* @param {Object} obj - input field object -* @returns {PositiveInteger} number of bytes -*/ -function byteLength( obj ) { - var nb; - if ( obj.isStructType ) { - nb = obj.type.byteLength; - } else { - nb = bytesPerElement( obj.type ); - } - if ( obj.length ) { - nb *= obj.length; - } - return nb; -} - - -// EXPORTS // - -module.exports = byteLength; diff --git a/lib/byte_offsets.js b/lib/byte_offsets.js deleted file mode 100644 index 9d80d44..0000000 --- a/lib/byte_offsets.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var min = require( '@stdlib/math-base-special-fast-min' ); -var isUnionType = require( './is_union_type.js' ); - - -// FUNCTIONS // - -/** -* Sets alignment padding for one or more field objects. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {NonNegativeInteger} padding - alignment padding -* @returns {Array} input array -*/ -function setPadding( fields, padding ) { - var i; - for ( i = 0; i < fields.length; i++ ) { - fields[ i ].padding = padding; - } - return fields; -} - - -// MAIN // - -/** -* Computes the byte offset for each field. -* -* ## Notes -* -* - This function mutates each field object. -* -* @private -* @param {Array} fields - list of normalized field objects -* @param {PositiveInteger} max - maximum alignment -* @returns {Array} input array -*/ -function byteOffsets( fields, max ) { - var alignment; - var padding; - var offset; - var tmp; - var o; - var i; - var j; - - offset = 0; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - - // Resolve the alignment requirement for this field: - alignment = min( o.alignment, max ); - - // Align the current offset to the required boundary: - padding = ( alignment-(offset%alignment) ) % alignment; - offset += padding; - - // Set the padding for the previous member: - if ( i > 0 ) { - tmp = fields[ i-1 ]; - tmp.padding = padding; - if ( isUnionType( o ) ) { - setPadding( tmp.fields, padding ); - } - } - // Set the offset for the current member: - o.byteOffset = offset; - - // If the current member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - o.fields[ j ].byteOffset = offset; - } - } - // Advance the offset by the size, in bytes, of the member: - offset += o.byteLength; - } - // Compute the padding for the last member: - padding = ( alignment - (offset%alignment) ) % alignment; - - // Set the padding for the last member: - o.padding = padding; - - // If the last member is a union type, propagate the offset to its child field objects... - if ( isUnionType( o ) ) { - setPadding( o.fields, padding ); - } - - return fields; -} - - -// EXPORTS // - -module.exports = byteOffsets; diff --git a/lib/casting_modes.js b/lib/casting_modes.js deleted file mode 100644 index f5b55d1..0000000 --- a/lib/casting_modes.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CASTING_MODES = [ - 'none', - 'safe', - 'mostly-safe', - 'same-kind', - 'unsafe' -]; - - -// EXPORTS // - -module.exports = CASTING_MODES; diff --git a/lib/complex2boolean.js b/lib/complex2boolean.js deleted file mode 100644 index bcfe273..0000000 --- a/lib/complex2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a complex number to a boolean. -* -* @private -* @param {ComplexLike} value - input value -* @returns {boolean} result -*/ -function complex2boolean( value ) { - return Boolean( value.re || value.im ); -} - - -// EXPORTS // - -module.exports = complex2boolean; diff --git a/lib/complex2number.js b/lib/complex2number.js deleted file mode 100644 index 92cf949..0000000 --- a/lib/complex2number.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Converts a complex number to a number. -* -* @private -* @param {ComplexLike} value - input value -* @returns {number} result -*/ -function complex2number( value ) { - return value.re; -} - - -// EXPORTS // - -module.exports = complex2number; diff --git a/lib/create_prototype_accessors.js b/lib/create_prototype_accessors.js deleted file mode 100644 index e50842b..0000000 --- a/lib/create_prototype_accessors.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable id-length */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setNonEnumerableReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var getter = require( './getter.js' ); -var setter = require( './setter.js' ); - - -// MAIN // - -/** -* Assigns methods for accessing field values to a provided prototype. -* -* @private -* @param {Object} p - prototype -* @param {Array} fields - field objects -* @returns {Object} object containing accessors for each field -*/ -function createPrototypeAccessors( p, fields ) { - var get; - var set; - var out; - var o; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - get = getter( o ); - set = setter( o ); - if ( o.enumerable ) { - if ( o.writable ) { - setReadWriteAccessor( p, o.name, get, set ); - } else { - setReadOnlyAccessor( p, o.name, get ); - } - } else if ( o.writable ) { - setNonEnumerableReadWriteAccessor( p, o.name, get, set ); - } else { - setNonEnumerableReadOnlyAccessor( p, o.name, get ); - } - out[ o.name ] = [ get, set ]; - } - return out; -} - - -// EXPORTS // - -module.exports = createPrototypeAccessors; diff --git a/lib/ctor_name.js b/lib/ctor_name.js deleted file mode 100644 index 72223f7..0000000 --- a/lib/ctor_name.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var CTOR_NAME = 'Struct'; - - -// EXPORTS // - -module.exports = CTOR_NAME; diff --git a/lib/data_view_methods.js b/lib/data_view_methods.js deleted file mode 100644 index 1472ad9..0000000 --- a/lib/data_view_methods.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DATA_VIEW_METHODS = { - 'int8': { - 'get': 'getInt8', - 'set': 'setInt8' - }, - 'int16': { - 'get': 'getInt16', - 'set': 'setInt16' - }, - 'int32': { - 'get': 'getInt32', - 'set': 'setInt32' - }, - 'int64': { - 'get': 'getBigInt64', - 'set': 'setBigInt64' - }, - 'uint8': { - 'get': 'getUint8', - 'set': 'setUint8' - }, - 'uint16': { - 'get': 'getUint16', - 'set': 'setUint16' - }, - 'uint32': { - 'get': 'getUint32', - 'set': 'setUint32' - }, - 'uint64': { - 'get': 'getBigUint64', - 'set': 'setBigUint64' - }, - 'float16': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'float32': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'float64': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'complex32': { - 'get': 'getFloat16', - 'set': 'setFloat16' - }, - 'complex64': { - 'get': 'getFloat32', - 'set': 'setFloat32' - }, - 'complex128': { - 'get': 'getFloat64', - 'set': 'setFloat64' - }, - 'bool': { - 'get': 'getUint8', - 'set': 'setUint8' - } -}; - - -// EXPORTS // - -module.exports = DATA_VIEW_METHODS; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index bd77c61..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dtypes": { - "real": "float64", - "complex": "complex128" - } -} diff --git a/lib/dtypes.js b/lib/dtypes.js deleted file mode 100644 index f78bc9e..0000000 --- a/lib/dtypes.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var DTYPES = [ - 'int8', - 'int16', - 'int32', - 'int64', - - 'uint8', - 'uint16', - 'uint32', - 'uint64', - - // 'float16', // TODO: uncomment once supported - - 'float32', - 'float64', - - // 'complex32', // TODO: uncomment once supported - - 'complex64', - 'complex128', - - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/lib/field_index.js b/lib/field_index.js deleted file mode 100644 index ae050da..0000000 --- a/lib/field_index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var indexOf = require( '@stdlib/array-base-index-of' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns the index of a specified field name in a provided list of field names. -* -* @private -* @param {Array} names - list of field names -* @param {string} name - field name -* @throws {Error} struct must have at least one field -* @throws {TypeError} must provide a recognized field name -* @returns {(integer|Error)} index or an error object -*/ -function fieldIndex( names, name ) { - var idx; - if ( names.length === 0 ) { - return new Error( 'invalid operation. struct does not have any fields.' ); - } - idx = indexOf( names, name, 0 ); - if ( idx < 0 ) { - return new TypeError( format( 'invalid argument. Field name must be one of the following: "%s". Value: `%s`.', join( names, ', ' ), name ) ); - } - return idx; -} - - -// EXPORTS // - -module.exports = fieldIndex; diff --git a/lib/field_names.js b/lib/field_names.js deleted file mode 100644 index b83b5f3..0000000 --- a/lib/field_names.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Resolves a list of field names. -* -* @private -* @param {Array} fields - list of field objects -* @returns {(Array|Error)} list of field names or an error -*/ -function fieldNames( fields ) { - var hash; - var out; - var o1; - var o2; - var i; - var j; - var k; - - hash = {}; - out = []; - for ( i = 0; i < fields.length; i++ ) { - o1 = fields[ i ]; - k = o1.name; - if ( isUnionType( o1 ) ) { - for ( j = 0; j < o1.fields.length; j++ ) { - o2 = o1.fields[ j ]; - k = o2.name; - if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } - hash[ k ] = true; - out.push( k ); - } - } else if ( hash[ k ] === true ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects having unique field names. Value: `%s`.', JSON.stringify( fields ) ) ); - } else { - hash[ k ] = true; - out.push( k ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fieldNames; diff --git a/lib/field_properties.js b/lib/field_properties.js deleted file mode 100644 index 7c4e487..0000000 --- a/lib/field_properties.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var FIELD_PROPERTIES = [ - 'name', - 'type', - 'description', - 'length', - 'enumerable', - 'writable', - 'default', - 'castingMode' -]; - - -// EXPORTS // - -module.exports = FIELD_PROPERTIES; diff --git a/lib/flatten_fields.js b/lib/flatten_fields.js deleted file mode 100644 index 6c7c99a..0000000 --- a/lib/flatten_fields.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUnionType = require( './is_union_type.js' ); - - -// MAIN // - -/** -* Flattens a list of field objects. -* -* @private -* @param {Array} fields - list of field objects -* @returns {Array} new list -*/ -function flatten( fields ) { - var out; - var o; - var i; - var j; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( isUnionType( o ) ) { - for ( j = 0; j < o.fields.length; j++ ) { - out.push( o.fields[ j ] ); - } - } else { - out.push( o ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/lib/format_layout.js b/lib/format_layout.js deleted file mode 100644 index e11ce83..0000000 --- a/lib/format_layout.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string-base-replace' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Returns a new regular expression for matching byte parameters. -* -* @private -* @returns {RegExp} regular expression -*/ -function reByteOffset() { - return /\[(\d{1,}),/g; -} - -/** -* Returns a function for replacing byte values in a serialized struct. -* -* @private -* @param {NonNegativeInteger} offset - byte offset -* @returns {Function} replacer function -*/ -function replacer( offset ) { - return wrapped; - - /** - * Callback invoked for each match. - * - * @private - * @param {string} match - matched substring - * @param {string} p1 - first matched capture group substring - * @returns {string} replacement string - */ - function wrapped( match, p1 ) { - return format( '[%u,', offset+parseInt( p1, 10 ) ); - } -} - - -// MAIN // - -/** -* Serializes a struct to a layout format. -* -* ## Notes -* -* - The output format is a multi-column format having the following layout: -* -* ```text -* | ...[byte_offset,byte_length] | -* ``` -* -* For example, -* -* ```text -* |[0,8]|[8,1]|[16,16]|[32,8]| -* ``` -* -* @private -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function layoutFormat( fields ) { - var out; - var tmp; - var re; - var N; - var o; - var i; - - N = fields.length; - - // Create a new regular expression for matching byte offsets: - re = reByteOffset(); - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // If the current type is a struct, we need to serialize and then post-process... - if ( o.isStructType ) { - out.push( replace( o.type.layout, re, replacer( o.byteOffset ) ) ); - continue; - } - // Format the field data: - out.push( format( '|<%s>[%u,%u]', o.type, o.byteOffset, o.byteLength ) ); - } - tmp = format( '%s|', out.join( '' ) ); - - // If we having a trailing `||` due to a nested struct, remove the final `|`: - if ( tmp[ tmp.length-2 ] === '|' ) { - tmp = tmp.substring( 0, tmp.length-1 ); - } - return tmp; -} - - -// EXPORTS // - -module.exports = layoutFormat; diff --git a/lib/format_linear.js b/lib/format_linear.js deleted file mode 100644 index f8c9095..0000000 --- a/lib/format_linear.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Serializes a struct to a linear string format. -* -* ## Notes -* -* - The output format is a three-column format having the following layout: -* -* ```text -* | byte_number | [field|padding] | notes | -* ``` -* -* - Nested `struct` instances are intentionally treated as opaque types, as we have limited access to struct internals (e.g., packed versus unpacked, field padding, etc), and we would effectively have to recompute all alignments and associated field data for the purposes of rendering. A user can always separately render a nested `struct` instance to a string in order to better understand its layout independently of its surrounding context in a parent `struct` instance. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @returns {string} string representation -*/ -function linearFormat( Struct, fields ) { - var nbytes; - var fmt0; - var fmt1; - var fmt2; - var bfmt; - var ufmt; - var fmt; - var tmp; - var out; - var flg; - var ib; - var c0; - var c1; - var c2; - var w0; - var w1; - var w; - var N; - var o; - var f; - var t; - var i; - var j; - var k; - - N = fields.length; - - // Resolve the size of the struct: - nbytes = Struct.byteLength; - - // Compute the width of the first column: - w0 = ( nbytes-1 ).toString().length; - - // Define a format string for the first column: - fmt0 = '%'+w0+'s'; - - // Determine the longest field name... - w1 = 0; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // Format: [] - w = o.name.length + 1 + ( o.byteLength-1 ).toString().length + 1; - if ( w > w1 ) { - w1 = w; - } - } - // Define a format string for the second column: - fmt1 = '%'+w1+'s'; - - // Define a format string for the third column: - fmt2 = '// %s'; - - // Define a format string which combines the columns: - fmt = '%s: %s %s'; - - // Initialize a byte counter: - ib = 0; - - out = []; - for ( i = 0; i < N; i++ ) { - o = fields[ i ]; - - // If we are currently processing fields in a union, move along to the next non-union field... - if ( i > 0 && ( o.byteOffset === fields[ i-1 ].byteOffset ) ) { - continue; - } - // Check whether this field is the first field of a union... - if ( i < N-1 ) { - flg = ( o.byteOffset === fields[ i+1 ].byteOffset ); - } else { - flg = false; - } - for ( j = 0; j < o.byteLength; j++ ) { - // In the first column, render the byte number: - c0 = format( fmt0, ib.toString() ); - - // In the second column, render the field name and the byte number relative to the field: - c1 = format( fmt1, format( '%s[%u]', o.name, j ) ); - - // If a field type spans multiple bytes, render the byte number: - if ( o.alignment > 1 ) { - bfmt = ' (byte %u)'; - } else { - bfmt = ''; - } - // If a field is part of a union, make that explicit: - if ( flg ) { - ufmt = ' => union: %s'; - tmp = []; - k = i + 1; - while ( k < N && o.byteOffset === fields[ k ].byteOffset ) { - f = fields[ k ]; - if ( f.isStructType ) { - t = ''; - } else { - t = f.type; - } - tmp.push( format( '%s<%s>[%u]', f.name, t, j%f.alignment ) ); - k += 1; - } - ufmt = format( ufmt, tmp.join( ', ' ) ); - } else { - ufmt = ''; - } - tmp = format( bfmt+ufmt, j%o.alignment ); - - // If a field contains multiple elements (i.e., is an array), render the field type along with the element number: - if ( o.length ) { - c2 = format( fmt2, format( '%s[%u]%s', o.type, floor( j/o.alignment ), tmp ) ); - } - // Otherwise, just render the field type: - else { - c2 = format( fmt2, format( '%s%s', o.type, tmp ) ); - } - // Render the row string: - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - for ( j = 0; j < o.padding; j++ ) { - c0 = format( fmt0, ib.toString() ); - c1 = format( fmt1, '--' ); - c2 = format( fmt2, 'padding' ); - out.push( format( fmt, c0, c1, c2 ) ); - ib += 1; - } - } - return out.join( '\n' ); -} - - -// EXPORTS // - -module.exports = linearFormat; diff --git a/lib/get_bigint.js b/lib/get_bigint.js deleted file mode 100644 index 9cbdd1f..0000000 --- a/lib/get_bigint.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBigInt( obj, method ) { - return getter; - - /** - * Reads a BigInt value from an underlying byte buffer. - * - * @private - * @returns {BigInt} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getBigInt; diff --git a/lib/get_boolean.js b/lib/get_boolean.js deleted file mode 100644 index 49cb9e7..0000000 --- a/lib/get_boolean.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getBoolean( obj, method ) { - return getter; - - /** - * Reads a boolean value from an underlying byte buffer. - * - * @private - * @returns {boolean} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return Boolean( view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ) ); - } -} - - -// EXPORTS // - -module.exports = getBoolean; diff --git a/lib/get_complex.js b/lib/get_complex.js deleted file mode 100644 index ea97cb9..0000000 --- a/lib/get_complex.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var complex = require( '@stdlib/complex-cmplx' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// VARIABLES // - -var CMPLX_TO_REAL = { - 'complex128': 'float64', - 'complex64': 'float32', - 'complex32': 'float16' -}; - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getComplex( obj, method ) { - return getter; - - /** - * Reads a complex number from an underlying byte buffer. - * - * @private - * @returns {Complex} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - var re = view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - var im = view[ method ]( obj.byteOffset+(obj.byteLength/2), IS_LITTLE_ENDIAN ); - return complex( re, im, CMPLX_TO_REAL[ obj.type ] ); - } -} - - -// EXPORTS // - -module.exports = getComplex; diff --git a/lib/get_number.js b/lib/get_number.js deleted file mode 100644 index 454ae92..0000000 --- a/lib/get_number.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for resolving field data -*/ -function getNumber( obj, method ) { - return getter; - - /** - * Reads a number value from an underlying byte buffer. - * - * @private - * @returns {number} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return view[ method ]( obj.byteOffset, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = getNumber; diff --git a/lib/get_struct.js b/lib/get_struct.js deleted file mode 100644 index 9809d30..0000000 --- a/lib/get_struct.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStruct( obj ) { - return getter; - - /** - * Returns a `struct` view of an underlying byte buffer. - * - * @private - * @returns {Object} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return new obj.type( view.buffer, view.byteOffset+obj.byteOffset, obj.byteLength ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getStruct; diff --git a/lib/get_struct_array.js b/lib/get_struct_array.js deleted file mode 100644 index e77507f..0000000 --- a/lib/get_struct_array.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getStructArray( obj ) { - return getter; - - /** - * Returns a list of `struct` views of an underlying byte buffer. - * - * @private - * @returns {Array} result - */ - function getter() { - var offset; - var view; - var out; - var i; - - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - out = []; - for ( i = 0; i < obj.length; i++ ) { - out.push( new obj.type( view.buffer, offset, obj.byteLength ) ); - offset += obj.byteOffset; - } - return out; - } -} - - -// EXPORTS // - -module.exports = getStructArray; diff --git a/lib/get_typedarray.js b/lib/get_typedarray.js deleted file mode 100644 index 3fbe534..0000000 --- a/lib/get_typedarray.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var typedarray = require( '@stdlib/array-typed' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for resolving field data -*/ -function getTypedArray( obj ) { - return getter; - - /** - * Returns a typed array view of an underlying byte buffer. - * - * @private - * @returns {TypedArray} result - */ - function getter() { - var view = this[ PRIVATE_BUFFER ]; - return typedarray( view.buffer, view.byteOffset+obj.byteOffset, obj.length, obj.type ); // eslint-disable-line max-len - } -} - - -// EXPORTS // - -module.exports = getTypedArray; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index efd1f9c..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var getNumber = require( './get_number.js' ); -var getBoolean = require( './get_boolean.js' ); -var getComplex = require( './get_complex.js' ); -var getBigInt = require( './get_bigint.js' ); -var getStruct = require( './get_struct.js' ); -var getTypedArray = require( './get_typedarray.js' ); -var getStructArray = require( './get_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for resolving field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for resolving field data -*/ -function getter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return getStructArray( obj ); - } - return getTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return getNumber( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'int64': - case 'uint64': - return getBigInt( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'bool': - return getBoolean( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - case 'complex128': - case 'complex64': - case 'complex32': - return getComplex( obj, DATA_VIEW_METHODS[ obj.type ].get ); - - default: - if ( obj.isStructType ) { - return getStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/has_properties.js b/lib/has_properties.js deleted file mode 100644 index 4efa706..0000000 --- a/lib/has_properties.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasProp = require( '@stdlib/assert-has-property' ); - - -// MAIN // - -/** -* Tests whether an object has a list of properties. -* -* @private -* @param {Object} obj - input object -* @param {Array} keys - list of property names -* @returns {boolean} result -*/ -function hasProperties( obj, keys ) { - var i; - for ( i = 0; i < keys.length; i++ ) { - if ( !hasProp( obj, keys[ i ] ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasProperties; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 66b138b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @module @stdlib/dstructs-struct -* -* @example -* var factory = require( '@stdlib/dstructs-struct' ); -* -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/init_field_object.js b/lib/init_field_object.js deleted file mode 100644 index f27784d..0000000 --- a/lib/init_field_object.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an initialized field object. -* -* @private -* @returns {Object} initialized field object -*/ -function initFieldObject() { - return { - 'isStructType': false, - 'description': '', - 'byteLength': 0, - 'byteOffset': 0, - 'alignment': 0, - 'padding': 0, - 'enumerable': true, - 'writable': true, - 'default': void 0, // explicitly set to `undefined` - 'castingMode': 'none' - }; -} - - -// EXPORTS // - -module.exports = initFieldObject; diff --git a/lib/is_struct_instance.js b/lib/is_struct_instance.js deleted file mode 100644 index 45867e0..0000000 --- a/lib/is_struct_instance.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isDataView = require( '@stdlib/assert-is-dataview' ); -var isObject = require( '@stdlib/assert-is-object' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `struct` instance. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `struct` instance -*/ -function isStructInstance( value ) { - // NOTE: the following is a relatively weak test, but we cannot use `instanceof` checks, etc, due to the factory nature of the implementation. Regardless, here, we are just trying to sniff out a `struct` type. If calling as a constructor later fails, we punt the responsibility off to the user to handle what should be an edge case. If, in the future, this check proves insufficient, we can add further "brand" checks... - return ( - isObject( value ) && - isDataView( value[ PRIVATE_BUFFER ] ) - ); -} - - -// EXPORTS // - -module.exports = isStructInstance; diff --git a/lib/is_union_type.js b/lib/is_union_type.js deleted file mode 100644 index 0230e40..0000000 --- a/lib/is_union_type.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); - - -// MAIN // - -/** -* Returns a boolean indicating whether a field object represents a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {boolean} result -*/ -function isUnionType( obj ) { - return obj.type === 'union' && isCollection( obj.fields ); -} - - -// EXPORTS // - -module.exports = isUnionType; diff --git a/lib/is_valid_boolean.js b/lib/is_valid_boolean.js deleted file mode 100644 index d375c2c..0000000 --- a/lib/is_valid_boolean.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid boolean field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidBoolean( value, name ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a boolean. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidBoolean; diff --git a/lib/is_valid_nonempty_string.js b/lib/is_valid_nonempty_string.js deleted file mode 100644 index 65da8da..0000000 --- a/lib/is_valid_nonempty_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidNonEmptyString( value, name ) { - if ( isString( value ) || value.length > 0 ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a non-empty string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidNonEmptyString; diff --git a/lib/is_valid_one_of.js b/lib/is_valid_one_of.js deleted file mode 100644 index b5fa15e..0000000 --- a/lib/is_valid_one_of.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns a function for testing whether a provided value is a valid enumerated field. -* -* @private -* @param {Collection} values - list of possible values -* @returns {Function} output function -*/ -function isValidOneOf( values ) { - return isValid; - - /** - * Tests whether a provided value is a valid enumerated field. - * - * @private - * @param {*} value - input value - * @param {string} name - field name - * @returns {(null|TypeError)} error object or null - */ - function isValid( value, name ) { - if ( contains( values, value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be one of the following: "%s". Value: `%s`.', name, join( values, ', ' ), value ) ); - } -} - - -// EXPORTS // - -module.exports = isValidOneOf; diff --git a/lib/is_valid_positive_integer.js b/lib/is_valid_positive_integer.js deleted file mode 100644 index 013600e..0000000 --- a/lib/is_valid_positive_integer.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid positive integer field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidPositiveInteger( value, name ) { - if ( isPositiveInteger( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a positive integer. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidPositiveInteger; diff --git a/lib/is_valid_string.js b/lib/is_valid_string.js deleted file mode 100644 index 89e4a03..0000000 --- a/lib/is_valid_string.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid string field. -* -* @private -* @param {*} value - input value -* @param {string} name - field name -* @returns {(null|TypeError)} error object or null -*/ -function isValidString( value, name ) { - if ( isString( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be a string. Value: `%s`.', name, value ) ); -} - - -// EXPORTS // - -module.exports = isValidString; diff --git a/lib/is_valid_type.js b/lib/is_valid_type.js deleted file mode 100644 index 487a32e..0000000 --- a/lib/is_valid_type.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var contains = require( '@stdlib/array-base-assert-contains' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DTYPES = require( './dtypes.js' ); - - -// MAIN // - -/** -* Tests whether a provided value is a valid `type` field. -* -* @private -* @param {*} value - input value -* @returns {(null|TypeError)} error object or null -*/ -function isValidType( value ) { - if ( contains( DTYPES, value ) || isStructConstructorLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid argument. `%s` field must be either a struct type or one of the following: "%s". Value: `%s`.', 'type', join( DTYPES, ', ' ), value ) ); -} - - -// EXPORTS // - -module.exports = isValidType; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bf3bfa8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,523 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, id-length, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var min = require( '@stdlib/math-base-special-fast-min' ); -var filled = require( '@stdlib/array-base-filled' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var CTOR_NAME = require( './ctor_name.js' ); -var createPrototypeAccessors = require( './create_prototype_accessors.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var normalize = require( './normalize_field_list.js' ); -var fieldNames = require( './field_names.js' ); -var fieldIndex = require( './field_index.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); -var byteOffsets = require( './byte_offsets.js' ); -var partitions = require( './partitions.js' ); -var flatten = require( './flatten_fields.js' ); -var struct2string = require( './to_string.js' ); -var struct2json = require( './to_json.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// MAIN // - -/** -* Returns a constructor for creating a fixed-width composite data type (a.k.a., a `struct`). -* -* @param {ObjectArray} fields - structure fields -* @throws {TypeError} first argument must be an array-like object containing objects -* @throws {TypeError} field objects must have required properties -* @throws {TypeError} field objects must have valid fields -* @throws {TypeError} union types must be array-like objects containing objects -* @throws {RangeError} union types must contain fields having the same byte length -* @throws {TypeError} union types cannot contain nested union types -* @throws {TypeError} union types can only contain one field with a default value -* @throws {Error} unexpected error -* @returns {Function} constructor -* -* @example -* var fields = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'double', -* 'description': 'double-precision floating-point number', -* 'type': 'float64', -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* }, -* { -* 'name': 'words', -* 'description': 'high and low words', -* 'type': 'uint32', -* 'length': 2, -* 'enumerable': true, -* 'writable': true, -* 'castingMode': 'none' -* } -* ] -* } -* ]; -* var Struct = factory( fields ); -* -* var data = { -* 'double': 3.14 -* }; -* var s = new Struct( data ); -* // returns -* -* var v = s.double; -* // returns 3.14 -* -* var w = s.words; -* // e.g., [ 1374389535, 1074339512 ] -*/ -function factory( fields ) { - var FIELD_NAMES; - var BYTE_LENGTH; - var PARTITIONS; - var ALIGNMENT; - var ACCESSORS; - var FIELDS; - var tmp; - var o; - if ( !isCollection( fields ) ) { - throw new TypeError( format( 'null2O', fields ) ); - } - // Normalize the list of field objects: - tmp = normalize( fields ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELDS = tmp; - - // Resolve the list of unique field names: - tmp = fieldNames( FIELDS ); - if ( tmp instanceof Error ) { - throw tmp; - } - FIELD_NAMES = tmp; - - // Resolve the struct's alignment requirements: - ALIGNMENT = resolveAlignment( FIELDS ); - - // Compute the byte offset for each field: - FIELDS = byteOffsets( FIELDS, ALIGNMENT ); - - // Now that we've finished processing provided field objects, flatten the list, such that union types are implied by field objects having the same byte offset: - FIELDS = flatten( FIELDS ); - - // Compute field "partitions" (i.e., non-overlapping views): - PARTITIONS = partitions( FIELDS ); - - // Compute the struct's byte length: - o = FIELDS[ FIELDS.length-1 ]; - BYTE_LENGTH = o.byteOffset + o.byteLength + o.padding; - - /** - * Constructor for a composite data type (a.k.a., a `struct`). - * - * @private - * @param {(Object|ArrayBuffer)} [arg] - array buffer or data object - * @param {NonNegativeInteger} [byteOffset=0] - offset, in bytes, to the first byte in a provided buffer for the returned `struct` to reference - * @param {NonNegativeInteger} [byteLength] - maximum number of elements in the byte array - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {Error} union types may only be initialized by a single member - * @returns {Struct} struct instance - */ - function Struct( arg, byteOffset, byteLength ) { - var values; - var nargs; - var cache; - var view; - var obj; - var o; - var v; - var i; - var j; - var k; - - nargs = arguments.length; - if ( !( this instanceof Struct ) ) { - if ( nargs === 0 ) { - return new Struct(); - } - if ( nargs === 1 ) { - return new Struct( arg ); - } - if ( nargs === 2 ) { - return new Struct( arg, byteOffset ); - } - return new Struct( arg, byteOffset, byteLength ); - } - if ( isArrayBuffer( arg ) ) { - if ( nargs === 1 ) { - view = new DataView( arg, 0, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( nargs === 2 ) { - view = new DataView( arg, byteOffset, BYTE_LENGTH ); - } else { - if ( !isNonNegativeInteger( byteLength ) ) { - throw new TypeError( format( 'invalid argument. Byte length must be a nonnegative integer. Value: `%s`.', byteLength ) ); - } - view = new DataView( arg, byteOffset, min( byteLength, BYTE_LENGTH ) ); // eslint-disable-line max-len - } - } - if ( view.byteLength < BYTE_LENGTH ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer has insufficient capacity. Minimum capacity: `%u`.', BYTE_LENGTH ) ); - } - } else { - view = new DataView( new ArrayBuffer( BYTE_LENGTH ) ); - if ( nargs > 0 ) { - if ( !isObject( arg ) ) { - throw new TypeError( format( 'null3L', arg ) ); - } - obj = arg; - } - } - // Bind the byte buffer to the current instance: - setReadOnly( this, PRIVATE_BUFFER, view ); - - // If we were provided a data object, set provided fields... - if ( obj !== void 0 ) { - // Initialize an array containing values to set: - values = filled( void 0, FIELDS.length ); - - // For each field, determine whether a value has been specified... - cache = {}; - for ( i = 0; i < FIELDS.length; i++ ) { - k = FIELD_NAMES[ i ]; - j = PARTITIONS[ i ]; - if ( hasProp( obj, k ) ) { - // Check whether a value has already been specified for this view (i.e., via another union member)... - if ( cache[ j ] ) { - throw new Error( 'invalid argument. Union types may only be initialized by a single member.' ); - } - values[ i ] = obj[ k ]; - cache[ j ] = true; - } - } - // Perform a second pass over the fields to fill in default initial values... - for ( i = 0; i < FIELDS.length; i++ ) { - j = PARTITIONS[ i ]; - if ( cache[ j ] ) { - // Skip fields already having initial values... - continue; - } - o = FIELDS[ i ]; - if ( o.default !== void 0 ) { - values[ i ] = o.default; - } - } - // Set all fields with initialization values... - for ( i = 0; i < FIELDS.length; i++ ) { - v = values[ i ]; - if ( v !== void 0 ) { - ACCESSORS[ FIELD_NAMES[ i ] ][ 1 ].call( this, v ); - } - } - } - return this; - } - - /** - * Constructor name. - * - * @private - * @name name - * @memberof Struct - * @readonly - * @type {string} - * @default 'Struct' - */ - setReadOnly( Struct, 'name', CTOR_NAME ); - - /** - * Alignment. - * - * @private - * @name alignment - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'alignment', ALIGNMENT ); - - /** - * Size (in bytes) of the `struct`. - * - * @private - * @name byteLength - * @memberof Struct - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( Struct, 'byteLength', BYTE_LENGTH ); - - /** - * Returns a list of `struct` fields. - * - * @private - * @name fields - * @memberof Struct - * @readonly - * @type {Array} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'fields', function get() { - return FIELD_NAMES.slice(); - }); - - /** - * Returns a string corresponding to the `struct` layout. - * - * @private - * @name layout - * @memberof Struct - * @readonly - * @type {string} - */ - setNonEnumerableReadOnlyAccessor( Struct, 'layout', function get() { - // As this is not likely to be a commonly used API, intentionally recompute the layout format in order to avoid consuming memory for what could be a long string... - return layoutFormat( FIELDS ); - }); - - /** - * Returns the underlying byte buffer of a `struct`. - * - * @private - * @name bufferOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {ArrayBuffer} underlying byte buffer - */ - setReadOnly( Struct, 'bufferOf', function bufferOf( obj ) { - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - return obj[ PRIVATE_BUFFER ].buffer; - }); - - /** - * Returns the length, in bytes, of the value specified by the provided field name. - * - * @private - * @name byteLengthOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte length - */ - setReadOnly( Struct, 'byteLengthOf', function byteLengthOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteLength; - }); - - /** - * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name. - * - * @private - * @name byteOffsetOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {NonNegativeInteger} byte offset - */ - setReadOnly( Struct, 'byteOffsetOf', function byteOffsetOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].byteOffset; - }); - - /** - * Returns the description associated with a provided field name. - * - * @private - * @name descriptionOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {string} description - */ - setReadOnly( Struct, 'descriptionOf', function descriptionOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].description; - }); - - /** - * Returns a boolean indicating whether a provided value is a `struct` instance. - * - * @private - * @name isStruct - * @memberof Struct - * @readonly - * @type {Function} - * @param {*} value - input value - * @returns {boolean} boolean indicating whether a value is a `struct` instance - */ - setReadOnly( Struct, 'isStruct', function isStruct( value ) { - return ( - value instanceof Struct || - ( - isStructInstance( value ) && - isStructConstructorLike( value.constructor ) - ) - ); - }); - - /** - * Returns the type associated with a provided field name. - * - * @private - * @name typeOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {string} name - field name - * @throws {Error} struct must have at least one field - * @throws {TypeError} must provide a recognized field name - * @returns {(string|Object)} type - */ - setReadOnly( Struct, 'typeOf', function typeOf( name ) { - var idx = fieldIndex( FIELD_NAMES, name ); - if ( idx instanceof Error ) { - throw idx; - } - return FIELDS[ idx ].type; - }); - - /** - * Returns the underlying byte buffer of a `struct` as a `DataView`. - * - * @private - * @name viewOf - * @memberof Struct - * @readonly - * @type {Function} - * @param {Object} obj - struct instance - * @throws {TypeError} must provide a `struct` instance - * @returns {DataView} view of underlying byte buffer - */ - setReadOnly( Struct, 'viewOf', function viewOf( obj ) { - var buf; - if ( !isStructInstance( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a `struct` instance. Value: `%s`.', obj ) ); - } - buf = obj[ PRIVATE_BUFFER ]; - return new DataView( buf.buffer, buf.byteOffset, buf.byteLength ); - }); - - // Create prototype accessors for getting and setting field values: - ACCESSORS = createPrototypeAccessors( Struct.prototype, FIELDS ); - - /** - * Serializes a `struct` to a string. - * - * @private - * @name toString - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @param {Options} [options] - function options - * @param {string} [options.format='none'] - serialization format - * @throws {Error} `this` must be a struct instance - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {string} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toString', function toString() { - var opts; - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - if ( arguments.length > 0 ) { - opts = arguments[ 0 ]; - } else { - opts = {}; - } - return struct2string( Struct, FIELDS, opts ); - }); - - /** - * Serializes a `struct` to JSON. - * - * @private - * @name toJSON - * @memberof Struct.prototype - * @readonly - * @type {Function} - * @throws {Error} `this` must be a struct instance - * @returns {JSON} serialized `struct` instance - */ - setReadOnly( Struct.prototype, 'toJSON', function toJSON() { - if ( !( this instanceof Struct ) ) { - throw new Error( 'invalid invocation. `this` is not a struct instance.' ); - } - return struct2json( this, FIELDS ); - }); - - return Struct; -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/normalize_field.js b/lib/normalize_field.js deleted file mode 100644 index 633f85f..0000000 --- a/lib/normalize_field.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var join = require( '@stdlib/array-base-join' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var hasProperties = require( './has_properties.js' ); -var isValidNonEmptyString = require( './is_valid_nonempty_string.js' ); -var isValidString = require( './is_valid_string.js' ); -var isValidPositiveInteger = require( './is_valid_positive_integer.js' ); -var isValidBoolean = require( './is_valid_boolean.js' ); -var isValidType = require( './is_valid_type.js' ); -var isValidOneOf = require( './is_valid_one_of.js' ); -var initFieldObject = require( './init_field_object.js' ); -var byteLength = require( './byte_length.js' ); -var CASTING_MODES = require( './casting_modes.js' ); -var ALIGNMENTS = require( './alignments.js' ); - - -// VARIABLES // - -var MANDATORY_FIELD_NAMES = [ - 'name', - 'type' -]; - -var VALIDATORS = { - 'name': isValidNonEmptyString, - 'type': isValidType, - 'description': isValidString, - 'length': isValidPositiveInteger, - 'enumerable': isValidBoolean, - 'writable': isValidBoolean, - 'default': constantFunction( null ), - 'castingMode': isValidOneOf( CASTING_MODES ) -}; - - -// MAIN // - -/** -* Normalizes a provided field object. -* -* @private -* @param {Object} obj - input field object -* @param {Array} keys - list of keys to standardize -* @returns {(Object|Error)} output object or an error -*/ -function normalize( obj, keys ) { - var out; - var err; - var v; - var k; - var i; - - out = initFieldObject(); - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - if ( hasProp( obj, k ) ) { - v = obj[ k ]; - err = VALIDATORS[ k ]( v, k ); - if ( err ) { - return err; - } - out[ k ] = v; - } - } - if ( !hasProperties( out, MANDATORY_FIELD_NAMES ) ) { - return new TypeError( format( 'invalid argument. Field objects must have the following properties: "%s". Value: `%s`.', join( MANDATORY_FIELD_NAMES, ', ' ), JSON.stringify( obj ) ) ); - } - out.isStructType = isStructConstructorLike( out.type ); - out.byteLength = byteLength( out ); - if ( out.isStructType ) { - out.alignment = out.type.alignment; - } else { - out.alignment = ALIGNMENTS[ out.type ]; - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_field_list.js b/lib/normalize_field_list.js deleted file mode 100644 index 8f55deb..0000000 --- a/lib/normalize_field_list.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var isUnionType = require( './is_union_type.js' ); -var normalizeField = require( './normalize_field.js' ); -var normalizeUnion = require( './normalize_union.js' ); - - -// MAIN // - -/** -* Normalizes a list of field objects. -* -* @private -* @param {Array} fields - input fields -* @returns {(Array|Error)} normalized field objects or an error -*/ -function normalize( fields ) { - var out; - var tmp; - var o; - var i; - - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return new TypeError( format( 'invalid argument. First argument must be an array of objects. Value: `%s`. Index: `%d`.', o, i ) ); - } - // Check for a union type which is a collection of nested field objects which all have the same byte length... - if ( isUnionType( o ) ) { - tmp = normalizeUnion( o ); - if ( tmp === null ) { - return new TypeError( format( 'invalid argument. Union types must be an array of objects. Value: `%s`. Index: `%d`.', JSON.stringify( o ), i ) ); - } - if ( tmp instanceof Error ) { - return tmp; - } - } else { - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = normalize; diff --git a/lib/normalize_union.js b/lib/normalize_union.js deleted file mode 100644 index 74f77ab..0000000 --- a/lib/normalize_union.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-object' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var isUnionType = require( './is_union_type.js' ); -var FIELD_PROPERTIES = require( './field_properties.js' ); -var normalizeField = require( './normalize_field.js' ); -var resolveAlignment = require( './resolve_alignment.js' ); - - -// MAIN // - -/** -* Normalizes a field object representing a union type. -* -* @private -* @param {Object} obj - input field object -* @returns {(Object|null|Error)} normalized field object or error object -*/ -function normalizeUnion( obj ) { - var fields; - var dflg; - var out; - var tmp; - var len; - var o; - var i; - - fields = obj.fields; - if ( fields.length === 0 ) { - return null; - } - out = []; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - if ( !isObject( o ) ) { - return null; - } - if ( isUnionType( o ) ) { - return new TypeError( format( 'invalid argument. Union types cannot contain nested union types. Value: `%s`.', JSON.stringify( fields ) ) ); - } - if ( dflg === void 0 && hasProp( o, 'default' ) ) { - dflg = true; - } else if ( dflg === true && hasProp( o, 'default' ) ) { - return new TypeError( format( 'invalid argument. Union types can only contain one field with a default value. Value: `%s`.', JSON.stringify( fields ) ) ); - } - tmp = normalizeField( o, FIELD_PROPERTIES ); - if ( tmp instanceof Error ) { - return tmp; - } - if ( i === 0 ) { - len = tmp.byteLength; - } else if ( tmp.byteLength !== len ) { - return new RangeError( format( 'invalid argument. Union types must contain fields having the same byte length. Value: `%s`.', JSON.stringify( fields ) ) ); - } - out.push( tmp ); - } - return { - 'type': 'union', - 'fields': out, - 'byteLength': len, - 'byteOffset': 0, - 'alignment': resolveAlignment( out ), - 'padding': 0 - }; -} - - -// EXPORTS // - -module.exports = normalizeUnion; diff --git a/lib/number2boolean.js b/lib/number2boolean.js deleted file mode 100644 index f64b67b..0000000 --- a/lib/number2boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Converts a number to a boolean. -* -* @private -* @param {number} value - input value -* @returns {boolean} result -*/ -function number2boolean( value ) { - return Boolean( value ); -} - - -// EXPORTS // - -module.exports = number2boolean; diff --git a/lib/partitions.js b/lib/partitions.js deleted file mode 100644 index dc63618..0000000 --- a/lib/partitions.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a list of partition indices. -* -* ## Notes -* -* - This function partitions field objects according to whether a field object represents a unique "view" over an underlying byte buffer. Field objects within a union belong to the same partition. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {NonNegativeIntegerArray} list of indices -*/ -function partitions( fields ) { - var out; - var N; - var o; - var i; - var j; - - N = fields.length; - - out = []; - j = 0; - for ( i = 0; i < N-1; i++ ) { - o = fields[ i ]; - - // Check for the start of a union... - if ( o.byteOffset === fields[ i+1 ].byteOffset ) { - out.push( j ); - continue; - } - out.push( j ); - j += 1; - } - // Set the partition for the last field object: - out.push( j ); - - return out; -} - - -// EXPORTS // - -module.exports = partitions; diff --git a/lib/private_buffer.js b/lib/private_buffer.js deleted file mode 100644 index bd4202e..0000000 --- a/lib/private_buffer.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -// Define a property name which is unlikely to be used in end user code: -var PRIVATE_BUFFER = '__@@##$$@@__struct_buffer__@@$$##@@__'; - - -// EXPORTS // - -module.exports = PRIVATE_BUFFER; diff --git a/lib/resolve_alignment.js b/lib/resolve_alignment.js deleted file mode 100644 index d144812..0000000 --- a/lib/resolve_alignment.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves the struct's byte alignment. -* -* @private -* @param {Array} fields - list of normalized field objects -* @returns {PositiveInteger} alignment -*/ -function alignment( fields ) { - var max; - var v; - var i; - - max = 0; - for ( i = 0; i < fields.length; i++ ) { - v = fields[ i ].alignment; - if ( v > max ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = alignment; diff --git a/lib/set_bigint.js b/lib/set_bigint.js deleted file mode 100644 index 4154da0..0000000 --- a/lib/set_bigint.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Number = require( '@stdlib/number-ctor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2bigint = require( './boolean2bigint.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBigInt( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBigInt( value ) ) { - dt = 'int64'; // FIXME: support both int64 and uint64 - v = value; - } else if ( isNumber( value ) ) { - if ( isInteger( value ) ) { - dt = minDataType( value ); - v = BigInt( value ); - } else { - dt = defaults.dtypes.real; - v = BigInt( floor( value ) ); - } - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2bigint( value ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = BigInt( floor( value.re ) ); // discard imaginary component - } else { - dt = 'generic'; - v = BigInt( floor( Number( v ) ) ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBigInt; diff --git a/lib/set_boolean.js b/lib/set_boolean.js deleted file mode 100644 index 02d1bda..0000000 --- a/lib/set_boolean.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var boolean2number = require( './boolean2number.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var bigint2boolean = require( './bigint2boolean.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setBoolean( obj, method ) { - return setter; - - /** - * Writes a boolean value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isNumber( value ) ) { - dt = defaults.dtypes.real; - v = boolean2number( number2boolean( value ) ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = boolean2number( bigint2boolean( value ) ); - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || defaults.dtypes.complex; - v = boolean2number( complex2boolean( value ) ); - } else { - dt = 'generic'; - v = Boolean( value ); - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setBoolean; diff --git a/lib/set_complex.js b/lib/set_complex.js deleted file mode 100644 index 5cd4315..0000000 --- a/lib/set_complex.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setComplex( obj, method ) { - return setter; - - /** - * Writes a complex number to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var re; - var im; - if ( isComplexLike( value ) ) { - dt = complexDType( value ) || obj.type; - re = value.re; - im = value.im; - } else if ( isNumber( value ) ) { - dt = ( obj.type === 'complex64' ) ? 'float32' : 'float64'; - re = value; - im = 0.0; - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - re = bigint2number( value ); - im = 0.0; - } else if ( isBoolean( value ) ) { - dt = 'bool'; - re = boolean2number( value ); - im = 0.0; - } else { - dt = 'generic'; - re = value; - im = 0.0; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, re, IS_LITTLE_ENDIAN ); - view[ method ]( obj.byteOffset+(obj.byteLength/2), im, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setComplex; diff --git a/lib/set_number.js b/lib/set_number.js deleted file mode 100644 index b7e5075..0000000 --- a/lib/set_number.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length -var isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var minDataType = require( '@stdlib/array-min-dtype' ); -var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' ); -var complexDType = require( '@stdlib/complex-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var boolean2number = require( './boolean2number.js' ); -var bigint2number = require( './bigint2number.js' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @param {string} method - data view method name -* @returns {Function} function for writing field data -*/ -function setNumber( obj, method ) { - return setter; - - /** - * Writes a number value to an underlying byte buffer. - * - * @private - * @param {*} value - value to set - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dt; - var v; - if ( isNumber( value ) ) { - if ( isRealFloatingPointDataType( obj.type ) ) { - dt = obj.type; - } else if ( !isInteger( value ) ) { - dt = defaults.dtypes.real; - } else if ( isSignedIntegerDataType( obj.type ) ) { - dt = minSignedIntegerDataType( value ); - } else { - dt = minDataType( value ); - } - v = value; - } else if ( isComplexLike( value ) ) { - dt = complexDType( value ) || ( ( obj.type === 'float32' ) ? 'complex64' : 'complex128' ); - v = value.re; // discard imaginary component - } else if ( isBoolean( value ) ) { - dt = 'bool'; - v = boolean2number( value ); - } else if ( isBigInt( value ) ) { - dt = 'int64'; // note: the specific integer data type (int64 vs uint64) should not matter here - v = bigint2number( value ); - } else { - dt = 'generic'; - v = value; - } - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - view = this[ PRIVATE_BUFFER ]; - view[ method ]( obj.byteOffset, v, IS_LITTLE_ENDIAN ); - } -} - - -// EXPORTS // - -module.exports = setNumber; diff --git a/lib/set_struct.js b/lib/set_struct.js deleted file mode 100644 index 63a0a76..0000000 --- a/lib/set_struct.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStruct( obj ) { - return setter; - - /** - * Writes `struct` data to an underlying byte buffer. - * - * @private - * @param {Object} value - value to set - * @throws {TypeError} must be a `struct` instance - * @throws {RangeError} must be a `struct` instance having the same byte length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var dest; - var src; - var buf; - var nb; - if ( !isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a `struct` instance. Value: `%s`.', obj.name, value ) ); - } - if ( obj.casting === 'none' && !( value instanceof obj.type ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, value ) ); - } - nb = obj.byteLength; - - buf = this.constructor.viewOf( value ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be a `struct` instance having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - - view = this[ PRIVATE_BUFFER ]; - dest = new Uint8Array( view.buffer, view.byteOffset+obj.byteOffset, nb ); // eslint-disable-line max-len - - gcopy( obj.length, src, 1, dest, 1 ); - } -} - - -// EXPORTS // - -module.exports = setStruct; diff --git a/lib/set_struct_array.js b/lib/set_struct_array.js deleted file mode 100644 index bbdcac3..0000000 --- a/lib/set_struct_array.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setStructArray( obj ) { - return setter; - - /** - * Writes a list of `struct` instances to an underlying byte buffer. - * - * @private - * @param {Collection} values - list of `struct` instances - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( values ) { - var offset; - var views; - var view; - var dest; - var src; - var buf; - var nb; - var i; - - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, values ) ); - } - if ( values.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - if ( obj.casting === 'none' ) { - for ( i = 0; i < values.length; i++ ) { - if ( !( values[ i ] instanceof obj.type ) ) { // note: this check will fail for cross-realm `struct` instances - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Value: `%s`.', obj.name, values[ i ] ) ); - } - } - } - // Compute the expected number of bytes per struct view: - nb = obj.byteLength / obj.length; // note: as a field is expected to have a homogeneous data type, the byte length should be evenly divisible by the number of elements - - // Check that all struct instances have the same byte length... - views = []; - for ( i = 0; i < values.length; i++ ) { - buf = this.constructor.viewOf( values[ i ] ); - if ( buf.byteLength !== nb ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object containing `struct` instances having the same byte length.', obj.name ) ); - } - src = new Uint8Array( buf.buffer, buf.byteOffset, nb ); - views.push( src ); - } - // Write the data for each `struct` to the underlying byte buffer... - view = this[ PRIVATE_BUFFER ]; - offset = view.byteOffset + obj.byteOffset; - for ( i = 0; i < values.length; i++ ) { - dest = new Uint8Array( view.buffer, offset, nb ); - gcopy( obj.length, views[ i ], 1, dest, 1 ); - offset += nb; - } - } -} - - -// EXPORTS // - -module.exports = setStructArray; diff --git a/lib/set_typedarray.js b/lib/set_typedarray.js deleted file mode 100644 index a56d413..0000000 --- a/lib/set_typedarray.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this, max-len */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isAllowedCast = require( '@stdlib/ndarray-base-assert-is-allowed-data-type-cast' ); -var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); -var typedarray = require( '@stdlib/array-typed' ); -var dtype = require( '@stdlib/array-dtype' ); -var reinterpretComplex = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var gfill = require( '@stdlib/blas-ext-base-gfill' ); -var map = require( '@stdlib/array-base-map' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var PRIVATE_BUFFER = require( './private_buffer.js' ); -var isStructInstance = require( './is_struct_instance.js' ); -var number2boolean = require( './number2boolean.js' ); -var complex2boolean = require( './complex2boolean.js' ); -var complex2number = require( './complex2number.js' ); - - -// MAIN // - -/** -* Returns a function for writing field data. -* -* @private -* @param {Object} obj - field object -* @returns {Function} function for writing field data -*/ -function setTypedArray( obj ) { - return setter; - - /** - * Writes a list of values to a typed array view of an underlying byte buffer. - * - * @private - * @param {Collection} value - value to set - * @throws {TypeError} must provide an array-like object - * @throws {RangeError} must provide an array-like object having an expected length - * @throws {TypeError} cannot cast provided values to field data type - */ - function setter( value ) { - var view; - var buf; - var dt; - if ( !isCollection( value ) || isStructInstance( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array-like object. Value: `%s`.', obj.name, value ) ); - } - if ( value.length !== obj.length ) { - throw new RangeError( format( 'invalid assignment. `%s` must be an array-like object having length %u.', obj.name, obj.length ) ); - } - dt = dtype( value ); - if ( !isAllowedCast( dt, obj.type, obj.castingMode ) ) { - throw new TypeError( format( 'invalid assignment. Assigned value cannot be cast to the data type of `%s`. Data types: [%s, %s].', obj.name, obj.type, dt ) ); - } - buf = this[ PRIVATE_BUFFER ]; - view = typedarray( buf.buffer, buf.byteOffset+obj.byteOffset, obj.length, obj.type ); - if ( dt === obj.type ) { - // Case: complex => complex - if ( isComplexDataType( dt ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: boolean => boolean - if ( isBooleanDataType( dt ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, reinterpretBoolean( view, 0 ), 1 ); - return; - } - // Case: real => real - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => ??? - if ( isRealDataType( dt ) ) { - // Case: real => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, value, 1, view, 1 ); - return; - } - // Case: real => complex - if ( isComplexDataType( obj.type ) ) { - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, value, 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - return; - } - // Case: real => boolean - map.assign( value, view, 1, 0, number2boolean ); - return; - } - // Case: complex => ??? - if ( isComplexDataType( dt ) ) { - // Case: complex => real - if ( isRealDataType( obj.type ) ) { - map.assign( value, view, 1, 0, complex2number ); // discard imaginary components - return; - } - // Case: complex => complex - if ( isComplexDataType( obj.type ) ) { - gcopy( obj.length*2, reinterpretComplex( value, 0 ), 1, reinterpretComplex( view, 0 ), 1 ); - return; - } - // Case: complex => boolean - map.assign( value, view, 1, 0, complex2boolean ); - return; - } - // Case: boolean => ??? - - // Case: boolean => real - if ( isRealDataType( obj.type ) ) { - gcopy( obj.length, reinterpretBoolean( value, 0 ), 1, view, 1 ); - return; - } - // Case: boolean => complex - view = reinterpretComplex( view, 0 ); - - // TODO: consider refactoring to avoid two-passes; may require creating a separate strided utility explicitly aimed at casting real-valued arrays to complex arrays - gcopy( obj.length, view, 2, reinterpretBoolean( value, 0 ), 1 ); // assign to only real-components - gfill.ndarray( obj.length, 0.0, view, 2, 1 ); // fill imaginary components with zeros - } -} - - -// EXPORTS // - -module.exports = setTypedArray; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index 8365f76..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var DATA_VIEW_METHODS = require( './data_view_methods.js' ); -var setNumber = require( './set_number.js' ); -var setComplex = require( './set_complex.js' ); -var setBoolean = require( './set_boolean.js' ); -var setBigInt = require( './set_bigint.js' ); -var setStruct = require( './set_struct.js' ); -var setTypedArray = require( './set_typedarray.js' ); -var setStructArray = require( './set_struct_array.js' ); - - -// MAIN // - -/** -* Returns a function for setting field data. -* -* @private -* @param {Object} obj - field object -* @throws {Error} unexpected error -* @returns {Function} function for setting field data -*/ -function setter( obj ) { - if ( obj.length ) { - if ( obj.isStructType ) { - return setStructArray( obj ); - } - return setTypedArray( obj ); - } - switch ( obj.type ) { - case 'float64': - case 'float32': - case 'float16': - case 'int8': - case 'int16': - case 'int32': - case 'uint8': - case 'uint16': - case 'uint32': - return setNumber( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'int64': - case 'uint64': - return setBigInt( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'bool': - return setBoolean( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - case 'complex128': - case 'complex64': - case 'complex32': - return setComplex( obj, DATA_VIEW_METHODS[ obj.type ].set ); - - default: - if ( obj.isStructType ) { - return setStruct( obj ); - } - // Ensure that we fail loudly if we have failed to add support for newly added data types: - throw new Error( format( 'unexpected error. Unrecognized data type. Value: `%s`.', obj.type ) ); - } -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/to_json.js b/lib/to_json.js deleted file mode 100644 index 1b06ccf..0000000 --- a/lib/to_json.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var typedarray2json = require( '@stdlib/array-to-json' ); -var isStructInstance = require( './is_struct_instance.js' ); - - -// MAIN // - -/** -* Serializes a `struct` instance to JSON. -* -* @private -* @param {Struct} struct - struct instance -* @param {Array} fields - list of normalized fields -* @returns {Object} JSON representation -*/ -function toJSON( struct, fields ) { - var out; - var o; - var v; - var i; - - out = {}; - for ( i = 0; i < fields.length; i++ ) { - o = fields[ i ]; - v = struct[ o.name ]; - if ( isCollection( v ) ) { - v = typedarray2json( v ); - } else if ( isStructInstance( v ) ) { - v = v.toJSON(); - } else if ( isComplexLike( v ) && isFunction( v.toJSON ) ) { - v = v.toJSON(); - } - out[ o.name ] = v; - } - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/to_string.js b/lib/to_string.js deleted file mode 100644 index c761c94..0000000 --- a/lib/to_string.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var contains = require( '@stdlib/array-base-assert-contains' ).factory; -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var linearFormat = require( './format_linear.js' ); -var layoutFormat = require( './format_layout.js' ); - - -// VARIABLES // - -var FORMATS = [ - 'none', - 'linear', - 'layout' -]; -var isFormat = contains( FORMATS ); - - -// MAIN // - -/** -* Serializes a struct to a string. -* -* @private -* @param {Function} Struct - struct constructor -* @param {Array} fields - list of normalized fields -* @param {Options} options - function options -* @param {string} [options.format] - serialization format -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {string} string representation -*/ -function toString( Struct, fields, options ) { // eslint-disable-line stdlib/no-redeclare - var opts; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2V', options ) ); - } - opts = { - 'format': 'none' - }; - if ( hasOwnProp( options, 'format' ) ) { - opts.format = options.format; - if ( !isFormat( opts.format ) ) { - throw new TypeError( format( 'null4S', 'format', join( FORMATS, ', ' ), options.format ) ); - } - } - if ( opts.format === 'linear' ) { - return linearFormat( Struct, fields ); - } - if ( opts.format === 'layout' ) { - return layoutFormat( fields ); - } - // Case: opts.format === 'none' - return ''; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index d8f8b2a..0869429 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Fixed-width composite data type (a.k.a., a `struct`).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,90 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-contains": "^0.2.3", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-real-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.2", - "@stdlib/array-base-filled": "^0.2.3", - "@stdlib/array-base-index-of": "^0.3.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-map": "^0.1.1", - "@stdlib/array-base-min-signed-integer-dtype": "^0.2.3", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-dataview": "^0.2.3", - "@stdlib/array-dtype": "^0.3.1", - "@stdlib/array-min-dtype": "^0.3.1", - "@stdlib/array-to-json": "^0.3.1", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-has-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex-like": "^0.2.4", - "@stdlib/assert-is-dataview": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-struct-constructor-like": "^0.1.1", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/blas-ext-base-gfill": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/complex-cmplx": "^0.2.3", - "@stdlib/complex-dtype": "^0.2.3", - "@stdlib/math-base-special-fast-min": "^0.3.1", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/ndarray-base-assert-is-allowed-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex": "^0.1.3", - "@stdlib/string-base-replace": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-constant-function": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/utils-define-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/number-float64-base-to-words": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "data structures", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ec1319b --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1c0e23c..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var struct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof struct, 'function', 'main export is a function' ); - t.end(); -}); - -// FIXME: add tests